home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Src Code / IEDIT16.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  97.9 KB  |  3,385 lines

  1. {**********************************************}
  2. { TeeChart Editor Dialog for Delphi 1.0 16bit  }
  3. { Copyright (c) 1995-1998 by David Berneda     }
  4. { All Rights Reserved                          }
  5. {**********************************************}
  6. unit IEdit16;
  7.  
  8. interface
  9.  
  10. uses
  11.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  12.   Forms, Chart, Buttons, Spin, AxMaxMin, AxisIncr, TeEngine, TeePrevi,
  13.   StdCtrls, ExtCtrls, TeeFunci, TeeProcs, TabNotBk;
  14.  
  15. Const MaxValueSources=16;
  16.  
  17.       teeEditMainPage    =0;
  18.       teeEditGeneralPage =1;
  19.       teeEditAxisPage    =2;
  20.       teeEditTitlePage   =3;
  21.       teeEditLegendPage  =4;
  22.       teeEditPanelPage   =5;
  23.       teeEditPagingPage  =6;
  24.       teeEditWallsPage   =7;
  25.       teeEdit3DPage      =8;
  26.  
  27.       dsStyle_NoData     =0;
  28.       dsStyle_Random     =1;
  29.       dsStyle_Function   =2;
  30.       dsStyle_Dataset    =3;
  31.  
  32. type
  33.   TChartEditorTab=( cetMain,
  34.                     cetGeneral,
  35.                     cetAxis,
  36.                     cetTitles,
  37.                     cetLegend,
  38.                     cetPanel,
  39.                     cetPaging,
  40.                     cetWalls,
  41.                     cet3D,
  42.                     cetSeriesGeneral,
  43.                     cetSeriesMarks
  44.                    );
  45.  
  46.   TChartEditForm=class;
  47.  
  48.   TChartEditorOption=( ceAdd, ceDelete, ceChange, ceClone, ceDataSource,
  49.                        ceTitle  );
  50.  
  51.   TChartEditorOptions=set of TChartEditorOption;
  52.  
  53.   TChartEditorHiddenTabs=set of TChartEditorTab;
  54.  
  55.   TOnChartFillFields=Procedure(AEditChartForm:TChartEditForm);
  56.   TOnChartIsDateTimeSource=Procedure( AComponent:TComponent;
  57.                                       Const ValueSource:String;
  58.                                       Var IsDateTime:Boolean);
  59.   TOnChartIsValidComponentSource=Function(AComponent:TComponent):Boolean;
  60.  
  61.   TChartEditForm = class(TForm)
  62.     MainPage: TTabbedNotebook;
  63.     Notebook1: TTabbedNotebook;
  64.     RGWhatAxis: TRadioGroup;
  65.     PageControlAxis: TTabbedNotebook;
  66.     Label5: TLabel;
  67.     Label8: TLabel;
  68.     LAxisMax: TLabel;
  69.     LAxisMin: TLabel;
  70.     Label6: TLabel;
  71.     LAxisIncre: TLabel;
  72.     CBAutomatic: TCheckBox;
  73.     CBLogarithmic: TCheckBox;
  74.     CBInverted: TCheckBox;
  75.     CBAutoMax: TCheckBox;
  76.     CBAutoMin: TCheckBox;
  77.     BAxisMax: TButton;
  78.     BAxisMin: TButton;
  79.     BAxisIncre: TButton;
  80.     Label14: TLabel;
  81.     Label3: TLabel;
  82.     Label9: TLabel;
  83.     EAxisTitle: TEdit;
  84.     BTitleFont: TButton;
  85.     SEAxisTitleAngle: TSpinEdit;
  86.     SEAxisTitleSize: TSpinEdit;
  87.     Label20: TLabel;
  88.     LabelAxisFormat: TLabel;
  89.     Label26: TLabel;
  90.     Label23: TLabel;
  91.     CBAxisLabels: TCheckBox;
  92.     CBLabelsOnAxis: TCheckBox;
  93.     CBRoundFirstLabel: TCheckBox;
  94.     EAxisValuesFormat: TEdit;
  95.     SEAxisLabelSepar: TSpinEdit;
  96.     BitBtn2: TButton;
  97.     SELabelsSize: TSpinEdit;
  98.     SEAxisLabelsAngle: TSpinEdit;
  99.     RGAxisLabelStyle: TRadioGroup;
  100.     Label28: TLabel;
  101.     Label29: TLabel;
  102.     Label30: TLabel;
  103.     Label31: TLabel;
  104.     BAxisPen: TButton;
  105.     BAxisTickPen: TButton;
  106.     BAxisTickInner: TButton;
  107.     SEAxisTickLength: TSpinEdit;
  108.     SEInnerTicksLength: TSpinEdit;
  109.     BAxisTickMinor: TButton;
  110.     BAxisGrid: TButton;
  111.     SEAxisMinorTickLen: TSpinEdit;
  112.     SEMinorCount: TSpinEdit;
  113.     CBAxisVisible: TCheckBox;
  114.     GBMargins: TGroupBox;
  115.     SETopMa: TSpinEdit;
  116.     SELeftMa: TSpinEdit;
  117.     SEBotMa: TSpinEdit;
  118.     SERightMa: TSpinEdit;
  119.     BPrint: TButton;
  120.     CBClipPoints: TCheckBox;
  121.     Label10: TLabel;
  122.     Label11: TLabel;
  123.     Label12: TLabel;
  124.     Label7: TLabel;
  125.     CBShowLeg: TCheckBox;
  126.     BLegColor: TButton;
  127.     BLegFont: TButton;
  128.     SETopLegPos: TSpinEdit;
  129.     SELegColWi: TSpinEdit;
  130.     CBLegStyle: TComboBox;
  131.     cbLegendStyle: TComboBox;
  132.     BLegendFrame: TButton;
  133.     CBResizeChart: TCheckBox;
  134.     CBLegendInverted: TCheckBox;
  135.     GroupBox1: TGroupBox;
  136.     Label25: TLabel;
  137.     BLegShadowCol: TButton;
  138.     SELegShadowSize: TSpinEdit;
  139.     Label2: TLabel;
  140.     Label19: TLabel;
  141.     RGBevelIn: TRadioGroup;
  142.     RGBevelOut: TRadioGroup;
  143.     CBPanelBorder: TCheckBox;
  144.     SEPanelWi: TSpinEdit;
  145.     BPanelColor: TButton;
  146.     SEPanelBor: TSpinEdit;
  147.     Label17: TLabel;
  148.     LabelPages: TLabel;
  149.     Label18: TLabel;
  150.     SEPointsPerPage: TSpinEdit;
  151.     ButtonPrevious: TBitBtn;
  152.     ButtonNext: TBitBtn;
  153.     CBScaleLast: TCheckBox;
  154.     BLastPage: TBitBtn;
  155.     BFirstPage: TBitBtn;
  156.     CBShowAxis: TCheckBox;
  157.     GroupBox4: TGroupBox;
  158.     CBGradientVisible: TCheckBox;
  159.     RGGradientDirection: TRadioGroup;
  160.     PaintBox1: TShape;
  161.     BGradientStart: TButton;
  162.     PaintBox2: TShape;
  163.     BGradientEnd: TButton;
  164.     BClose: TButton;
  165.     BExport: TButton;
  166.     CBTickOnLabels: TCheckBox;
  167.     RGPanning: TRadioGroup;
  168.     TabSubWalls: TTabbedNotebook;
  169.     CBView3dWalls: TCheckBox;
  170.     GBZoom: TGroupBox;
  171.     CBAllowZoom: TCheckBox;
  172.     CBAnimatedZoom: TCheckBox;
  173.     LAniZoomSteps: TLabel;
  174.     SEAniZoomSteps: TSpinEdit;
  175.     GroupBox7: TGroupBox;
  176.     RBLegendLeft: TRadioButton;
  177.     RBLegendRight: TRadioButton;
  178.     RBLegendBottom: TRadioButton;
  179.     RBLegendTop: TRadioButton;
  180.     Label1: TLabel;
  181.     SELegMargin: TSpinEdit;
  182.     Button1: TButton;
  183.     CBTitleVisible: TCheckBox;
  184.     CBTitleAdjust: TCheckBox;
  185.     BTitFont: TButton;
  186.     BTitleFrame: TButton;
  187.     BTitleBrush: TButton;
  188.     RGTitalign: TRadioGroup;
  189.     MTitle: TMemo;
  190.     CBTitles: TComboBox;
  191.     PageControlSeries: TTabbedNotebook;
  192.     GroupBox5: TGroupBox;
  193.     Label27: TLabel;
  194.     CBShowInLegend: TCheckBox;
  195.     CBSeriesCursor: TComboBox;
  196.     GroupBox2: TGroupBox;
  197.     Label15: TLabel;
  198.     Label21: TLabel;
  199.     EValueformat: TEdit;
  200.     EPercentFormat: TEdit;
  201.     RGHorizAxis: TRadioGroup;
  202.     RGVertAxis: TRadioGroup;
  203.     CBMarksVisible: TCheckBox;
  204.     GroupBox3: TGroupBox;
  205.     Label32: TLabel;
  206.     SEArrowLength: TSpinEdit;
  207.     BMarkLinCol: TButton;
  208.     RGMarkStyle: TRadioGroup;
  209.     GroupBox11: TGroupBox;
  210.     BMarksBackColor: TButton;
  211.     CBTransparent: TCheckBox;
  212.     BMarkFont: TButton;
  213.     BMarksFrame: TButton;
  214.     CBMarkClip: TCheckBox;
  215.     CBDataSourcestyle: TComboBox;
  216.     PageControl2: TNotebook;
  217.     Label16: TLabel;
  218.     CBListDataSets: TComboBox;
  219.     GroupFields: TScrollBox;
  220.     LabelLabels: TLabel;
  221.     CBLabelsField: TComboBox;
  222.     Label34: TLabel;
  223.     CBFunctions: TComboBox;
  224.     GroupBox9: TGroupBox;
  225.     Label22: TLabel;
  226.     Label24: TLabel;
  227.     LBAvailSeries: TListBox;
  228.     LBSelectedSeries: TListBox;
  229.     BRightOne: TButton;
  230.     BRightAll: TButton;
  231.     BLeftOne: TButton;
  232.     BLeftAll: TButton;
  233.     CBSeries: TComboBox;
  234.     ImageSeries: TImage;
  235.     LabelSeriesClass: TLabel;
  236.     LBSeries: TListBox;
  237.     HeaderControl1: THeader;
  238.     BMoveUP: TBitBtn;
  239.     BMoveDown: TBitBtn;
  240.     BAddSeries: TButton;
  241.     BDeleteSeries: TButton;
  242.     BRenameSeries: TButton;
  243.     BCloneSeries: TButton;
  244.     BChangeTypeSeries: TButton;
  245.     GroupBox6: TGroupBox;
  246.     RGBitmap: TRadioGroup;
  247.     BBrowseImage: TButton;
  248.     CBImageInside: TCheckBox;
  249.     CBXDateTime: TCheckBox;
  250.     CBYDateTime: TCheckBox;
  251.     Panel1: TPanel;
  252.     Label33: TLabel;
  253.     BWallColor: TButton;
  254.     SHWallColor: TShape;
  255.     BWallPen: TButton;
  256.     BWallBrush: TButton;
  257.     SEWallSize: TSpinEdit;
  258.     BWallColor2: TButton;
  259.     SHWallColor2: TShape;
  260.     BWallPen2: TButton;
  261.     BWallBrush2: TButton;
  262.     SEWallSize2: TSpinEdit;
  263.     Label4: TLabel;
  264.     SHWallColor3: TShape;
  265.     Button2: TButton;
  266.     Button3: TButton;
  267.     Button4: TButton;
  268.     SEWallSize3: TSpinEdit;
  269.     Label35: TLabel;
  270.     CBMultiLine: TCheckBox;
  271.     CBGridCenter: TCheckBox;
  272.     CBLeftWallTrans: TCheckBox;
  273.     CBBotWallTrans: TCheckBox;
  274.     CBBackWallTrans: TCheckBox;
  275.     GB3D: TGroupBox;
  276.     Label13: TLabel;
  277.     Label36: TLabel;
  278.     CBView3d: TCheckBox;
  279.     SE3d: TSpinEdit;
  280.     CBOrthogonal: TCheckBox;
  281.     SBZoom: TScrollBar;
  282.     Label37: TLabel;
  283.     SBRot: TScrollBar;
  284.     Label38: TLabel;
  285.     SBElev: TScrollBar;
  286.     Label39: TLabel;
  287.     Label40: TLabel;
  288.     SBHorizOf: TScrollBar;
  289.     SBVertOf: TScrollBar;
  290.     LZoom: TLabel;
  291.     LRot: TLabel;
  292.     LElev: TLabel;
  293.     LHorizOf: TLabel;
  294.     LVertOf: TLabel;
  295.     Label41: TLabel;
  296.     SEAxisPos: TSpinEdit;
  297.     Label42: TLabel;
  298.     SEAxisStart: TSpinEdit;
  299.     Label43: TLabel;
  300.     SEAxisEnd: TSpinEdit;
  301.     CBZoomFonts: TCheckBox;
  302.     CBWallDark: TCheckBox;
  303.     CBWallDarkBot: TCheckBox;
  304.     CBWallDarkBack: TCheckBox;
  305.     Button5: TButton;
  306.     Label44: TLabel;
  307.     SBPerspec: TScrollBar;
  308.     LPerspec: TLabel;
  309.     procedure SELegMarginChange(Sender: TObject);
  310.     procedure cbLegendStyleChange(Sender: TObject);
  311.     procedure SpinEdit2Change(Sender: TObject);
  312.     procedure BTitFontClick(Sender: TObject);
  313.     procedure BColGridClick(Sender: TObject);
  314.     procedure RGHorizAxisClick(Sender: TObject);
  315.     procedure FormShow(Sender: TObject);
  316.     procedure SpinEdit9Change(Sender: TObject);
  317.     procedure SETopLegPosChange(Sender: TObject);
  318.     procedure RGBevelInClick(Sender: TObject);
  319.     procedure RGBevelOutClick(Sender: TObject);
  320.     procedure CBPanelBorderClick(Sender: TObject);
  321.     procedure SEPanelWiChange(Sender: TObject);
  322.     procedure RGWhatAxisClick(Sender: TObject);
  323.     procedure CBAxisVisibleClick(Sender: TObject);
  324.     procedure SEAxisTickLengthChange(Sender: TObject);
  325.     procedure BLegFontClick(Sender: TObject);
  326.     procedure BPrintClick(Sender: TObject);
  327.     procedure BLegColorClick(Sender: TObject);
  328.     procedure BMarksBackColorClick(Sender: TObject);
  329.     procedure CBAutomaticClick(Sender: TObject);
  330.     procedure CBLegStyleChange(Sender: TObject);
  331.     procedure BBackColClick(Sender: TObject);
  332.     procedure CBShowLegClick(Sender: TObject);
  333.     procedure CBAllowZoomClick(Sender: TObject);
  334.     procedure CBClipPointsClick(Sender: TObject);
  335.     procedure CBTitleVisibleClick(Sender: TObject);
  336.     procedure EAxisTitleChange(Sender: TObject);
  337.     procedure BChartFrameClick(Sender: TObject);
  338.     procedure BLegendFrameClick(Sender: TObject);
  339.     procedure BTitleFontClick(Sender: TObject);
  340.     procedure FormCreate(Sender: TObject);
  341.     procedure MTitleChange(Sender: TObject);
  342.     procedure BAxisMaxClick(Sender: TObject);
  343.     procedure BAxisMinClick(Sender: TObject);
  344.     procedure BAxisIncreClick(Sender: TObject);
  345.     procedure BPanelColorClick(Sender: TObject);
  346.     procedure CBLogarithmicClick(Sender: TObject);
  347.     procedure BInnerTicksClick(Sender: TObject);
  348.     procedure SEInnerTicksLengthChange(Sender: TObject);
  349.     procedure ButtonNextClick(Sender: TObject);
  350.     procedure ButtonPreviousClick(Sender: TObject);
  351.     procedure SEPointsPerPageChange(Sender: TObject);
  352.     procedure CBScaleLastClick(Sender: TObject);
  353.     procedure BGradientStartClick(Sender: TObject);
  354.     procedure BGradientEndClick(Sender: TObject);
  355.     procedure RGGradientDirectionClick(Sender: TObject);
  356.     procedure CBGradientVisibleClick(Sender: TObject);
  357.     procedure BLastPageClick(Sender: TObject);
  358.     procedure BFirstPageClick(Sender: TObject);
  359.     procedure CBAnimatedZoomClick(Sender: TObject);
  360.     procedure CBResizeChartClick(Sender: TObject);
  361.     procedure BTitleFrameClick(Sender: TObject);
  362.     procedure CBFootAdjustClick(Sender: TObject);
  363.     procedure CBTitleAdjustClick(Sender: TObject);
  364.     procedure BTitleBrushClick(Sender: TObject);
  365.     procedure BMinorTicksClick(Sender: TObject);
  366.     procedure SEAxisMinorTickLenChange(Sender: TObject);
  367.     procedure SEMinorCountChange(Sender: TObject);
  368.     procedure SEPanelBorChange(Sender: TObject);
  369.     procedure CBShowAxisClick(Sender: TObject);
  370.     procedure CBAutoMaxClick(Sender: TObject);
  371.     procedure CBAutoMinClick(Sender: TObject);
  372.     procedure CBInvertedClick(Sender: TObject);
  373.     procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
  374.       Shift: TShiftState; X, Y: Integer);
  375.     procedure PaintBox2MouseUp(Sender: TObject; Button: TMouseButton;
  376.       Shift: TShiftState; X, Y: Integer);
  377.     procedure CBLegendInvertedClick(Sender: TObject);
  378.     procedure BLegShadowColClick(Sender: TObject);
  379.     procedure SELegShadowSizeChange(Sender: TObject);
  380.     procedure RGBitmapClick(Sender: TObject);
  381.     procedure SEAxisTitleAngleChange(Sender: TObject);
  382.     procedure SEAxisTitleSizeChange(Sender: TObject);
  383.     procedure CBAxisLabelsClick(Sender: TObject);
  384.     procedure SEAxisLabelsAngleChange(Sender: TObject);
  385.     procedure RGAxisLabelStyleClick(Sender: TObject);
  386.     procedure SELabelsSizeChange(Sender: TObject);
  387.     procedure CBLabelsOnAxisClick(Sender: TObject);
  388.     procedure SEAxisLabelSeparChange(Sender: TObject);
  389.     procedure CBRoundFirstLabelClick(Sender: TObject);
  390.     procedure EAxisValuesFormatChange(Sender: TObject);
  391.     procedure BitBtn2Click(Sender: TObject);
  392.     procedure CBView3dWallsClick(Sender: TObject);
  393.     procedure BWallPenClick(Sender: TObject);
  394.     procedure BWallBrushClick(Sender: TObject);
  395.     procedure BWallColorClick(Sender: TObject);
  396.     procedure BBottomWallPenClick(Sender: TObject);
  397.     procedure BBottomWallBrushClick(Sender: TObject);
  398.     procedure SEWallSizeChange(Sender: TObject);
  399.     procedure EValueformatChange(Sender: TObject);
  400.     procedure EPercentFormatChange(Sender: TObject);
  401.     procedure CBMarksVisibleClick(Sender: TObject);
  402.     procedure CBTransparentClick(Sender: TObject);
  403.     procedure CBMarkClipClick(Sender: TObject);
  404.     procedure SEArrowLengthChange(Sender: TObject);
  405.     procedure BMarkFontClick(Sender: TObject);
  406.     procedure BMarksFrameClick(Sender: TObject);
  407.     procedure BMarkLinColClick(Sender: TObject);
  408.     procedure BAxisPenClick(Sender: TObject);
  409.     procedure CBSeriesCursorChange(Sender: TObject);
  410.     procedure CBView3dClick(Sender: TObject);
  411.     procedure RGTitalignClick(Sender: TObject);
  412.     procedure RGVertAxisClick(Sender: TObject);
  413.     procedure BAxisTickPenClick(Sender: TObject);
  414.     procedure CBShowInLegendClick(Sender: TObject);
  415.     procedure CBListDataSetsChange(Sender: TObject);
  416.     procedure CBLabelsFieldChange(Sender: TObject);
  417.     procedure CBTickOnLabelsClick(Sender: TObject);
  418.     procedure BExportClick(Sender: TObject);
  419.     procedure RGMarkStyleClick(Sender: TObject);
  420.     procedure RGPanningClick(Sender: TObject);
  421.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  422.     procedure SHWallColorMouseUp(Sender: TObject; Button: TMouseButton;
  423.       Shift: TShiftState; X, Y: Integer);
  424.     procedure SEAniZoomStepsChange(Sender: TObject);
  425.     procedure RBLegendTopClick(Sender: TObject);
  426.     procedure RBLegendLeftClick(Sender: TObject);
  427.     procedure RBLegendRightClick(Sender: TObject);
  428.     procedure RBLegendBottomClick(Sender: TObject);
  429.     procedure BCloseClick(Sender: TObject);
  430.     procedure PageControlSeriesChanging(Sender: TObject;
  431.       var AllowChange: Boolean);
  432.     procedure MainPageChanging(Sender: TObject;
  433.       var AllowChange: Boolean);
  434.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  435.     procedure BRightOneClick(Sender: TObject);
  436.     procedure BLeftOneClick(Sender: TObject);
  437.     procedure BRightAllClick(Sender: TObject);
  438.     procedure BLeftAllClick(Sender: TObject);
  439.     procedure LBAvailSeriesDblClick(Sender: TObject);
  440.     procedure LBSelectedSeriesDblClick(Sender: TObject);
  441.     procedure CBFunctionsChange(Sender: TObject);
  442.     procedure Button1Click(Sender: TObject);
  443.     procedure CBDataSourcestyleChange(Sender: TObject);
  444.     procedure CBTitlesChange(Sender: TObject);
  445.     procedure CBSeriesChange(Sender: TObject);
  446.     procedure BMoveUPClick(Sender: TObject);
  447.     procedure BMoveDownClick(Sender: TObject);
  448.     procedure BAddSeriesClick(Sender: TObject);
  449.     procedure BDeleteSeriesClick(Sender: TObject);
  450.     procedure BRenameSeriesClick(Sender: TObject);
  451.     procedure BCloneSeriesClick(Sender: TObject);
  452.     procedure BChangeTypeSeriesClick(Sender: TObject);
  453.     procedure LBSeriesDrawItem(Control: TWinControl; Index: Integer;
  454.       Rect: TRect; State: TOwnerDrawState);
  455.     procedure LBSeriesDblClick(Sender: TObject);
  456.     procedure LBSeriesDragDrop(Sender, Source: TObject; X, Y: Integer);
  457.     procedure LBSeriesDragOver(Sender, Source: TObject; X, Y: Integer;
  458.       State: TDragState; var Accept: Boolean);
  459.     procedure LBSeriesKeyUp(Sender: TObject; var Key: Word;
  460.       Shift: TShiftState);
  461.     procedure LBSeriesMouseDown(Sender: TObject; Button: TMouseButton;
  462.       Shift: TShiftState; X, Y: Integer);
  463.     procedure BBrowseImageClick(Sender: TObject);
  464.     procedure CBImageInsideClick(Sender: TObject);
  465.     procedure CBXDateTimeClick(Sender: TObject);
  466.     procedure CBYDateTimeClick(Sender: TObject);
  467.     procedure LBSeriesClick(Sender: TObject);
  468.     procedure SE3dChange(Sender: TObject);
  469.     procedure SERightMaChange(Sender: TObject);
  470.     procedure SETopMaChange(Sender: TObject);
  471.     procedure SEBotMaChange(Sender: TObject);
  472.     procedure SELeftMaChange(Sender: TObject);
  473.     procedure Notebook1Change(Sender: TObject; NewTab: Integer;
  474.       var AllowChange: Boolean);
  475.     procedure PageControlAxisChange(Sender: TObject; NewTab: Integer;
  476.       var AllowChange: Boolean);
  477.     procedure MainPageChange(Sender: TObject; NewTab: Integer;
  478.       var AllowChange: Boolean);
  479.     procedure PageControlSeriesChange(Sender: TObject; NewTab: Integer;
  480.       var AllowChange: Boolean);
  481.     procedure TabSubWallsChange(Sender: TObject; NewTab: Integer;
  482.       var AllowChange: Boolean);
  483.     procedure CBOrthogonalClick(Sender: TObject);
  484.     procedure SBZoomChange(Sender: TObject);
  485.     procedure CBMultiLineClick(Sender: TObject);
  486.     procedure CBGridCenterClick(Sender: TObject);
  487.     procedure CBLeftWallTransClick(Sender: TObject);
  488.     procedure SBRotChange(Sender: TObject);
  489.     procedure SBElevChange(Sender: TObject);
  490.     procedure SBHorizOfChange(Sender: TObject);
  491.     procedure SBVertOfChange(Sender: TObject);
  492.     procedure SEAxisPosChange(Sender: TObject);
  493.     procedure SEAxisStartChange(Sender: TObject);
  494.     procedure SEAxisEndChange(Sender: TObject);
  495.     procedure CBZoomFontsClick(Sender: TObject);
  496.     procedure CBWallDarkBackClick(Sender: TObject);
  497.     procedure Button5Click(Sender: TObject);
  498.     procedure SBPerspecChange(Sender: TObject);
  499.   private
  500.     { Private declarations }
  501.     TheSeriesForms       : Array[1..4] of TForm;
  502.     NumSeriesForms       : Integer;
  503.     procedure Refresh3DControls;
  504.   protected
  505.     Function IsDataSet:Boolean; virtual;
  506.     Procedure FillFields; virtual;
  507.     Procedure FillSources(AItems:TStrings; AddCurrent:Boolean);
  508.     Function IsValidComponentSource(AComponent:TComponent):Boolean; virtual;
  509.     Procedure IsDateTimeSource( AComponent:TComponent;
  510.                                 Const ValueSource:String;
  511.                                 Var IsDateTime:Boolean); virtual;
  512.     Procedure AddSeriesForm(AForm:TForm; ATabIndex:Integer; ATag:Longint);
  513.     procedure DestroySeriesForms;
  514.   public
  515.     { Public declarations }
  516.     CreatingForm:Boolean;
  517.  
  518.     TheChart           : TCustomChart;
  519.     TheAxis            : TCustomChartAxis;
  520.     TheTitle           : TChartTitle;
  521.     TheWall            : TChartWall;
  522.     TheSeries          : TChartSeries;
  523.     TheEditSeries      : TChartSeries;
  524.     TheActivePageIndex : Longint;
  525.     TheHiddenTabs      : TChartEditorHiddenTabs;
  526.  
  527.     ApplyChangesFunction : Boolean;
  528.     ApplyChangesDataSet  : Boolean;
  529.  
  530.     EditorOptions        : TChartEditorOptions;
  531.     ComingFromDoubleClick: Boolean;
  532.  
  533.     OnChartFillFields:TOnChartFillFields;
  534.     OnChartIsDateTimeSource:TOnChartIsDateTimeSource;
  535.     OnChartIsValidComponentSource:TOnChartIsValidComponentSource;
  536.  
  537.     Procedure SetAxisLabels;
  538.     Procedure SetAxisTicks;
  539.     Procedure SetAxisTitle;
  540.     Procedure SetAxisScales;
  541.     Procedure SetAxisPosition;
  542.     procedure SetTabSeriesMarks;
  543.     procedure SetTabSeriesGeneral;
  544.     procedure SetTabSeriesDataSource;
  545.     procedure SetTabSeriesDatabase;
  546.     procedure SetTabSeriesFunctions;
  547.  
  548.     procedure SetTabTitle;
  549.     procedure SetTabWalls(AWall:TChartWall);
  550.  
  551.     Function AxisTitleOrName(Axis:TCustomChartAxis):String;
  552.     procedure TheChartPageChange(Sender: TObject);
  553.     procedure RepaintGradientColors;
  554.     Procedure CheckGradientVisible;
  555.     Function GetDateTimeStepText(tmp:TDateTimeStep):String;
  556.     procedure ProcGetCursors(const S: string);
  557.     procedure SetSelectedSourceDatabase;
  558.     procedure SetSelectedSourceSeries;
  559.     procedure FillSourceDataSets;
  560.     procedure FillSourceSeries;
  561.     procedure CBDateTimeClick(Sender: TObject);
  562.     procedure CBValuesChange(Sender: TObject);
  563.     Function SelectedTitle:TChartTitle;
  564.     Function SelectedWall:TChartWall;
  565.     Procedure EnableLegendMarginControls;
  566.     procedure EnableDataSourceControls(IsDatabase,IsFunction:Boolean);
  567.     procedure EnableListButtons;
  568.     Function GetSelectedSource:TComponent;
  569.     Function GetSourceCombo(Index:Integer):TComboBox;
  570.     procedure DoApplyChangesDataset;
  571.     procedure DoApplyChangesFunction;
  572.     procedure SetCurrentDataSource;
  573.     procedure SetTabSeries;
  574.     Procedure RefreshButtons;
  575.     procedure SwapSeries(tmp1,tmp2:Longint);
  576.     Function SelectedSeriesIndex:Integer;
  577.     Function SelectedSeries:TChartSeries;
  578.     procedure FillSeries(OldSeries:TChartSeries);
  579.     Function SeriesAtMousePos(Var p:TPoint):Longint;
  580.     Function PointInSection(Const P:TPoint; ASection:Longint):Boolean;
  581.     procedure BEditSeriesClick;
  582.     procedure CheckApplyChanges;
  583.     Procedure RefreshWallDark(AWall:TChartWall);
  584.     Procedure RefreshWallColorShape(AWall:TChartWall);
  585.     procedure EnableImageControls;
  586.     Function ChangeMargin(AEdit:TSpinEdit; APos,OtherSide:Integer):Integer;
  587.     Function InsertSeriesForm( EditorClass:TFormClass;
  588.                                Position:Integer;
  589.                                Const EditorTabName:String;
  590.                                AnObject:TPersistent):TForm;
  591.   end;
  592.  
  593.   TChartEditFormClass=class of TChartEditForm;
  594.  
  595. Type TOnCreateEditSeries=Procedure(Sender:TChartEditForm; AChart:TCustomChart);
  596. Var InternalOnCreateEditSeries:TOnCreateEditSeries;
  597.  
  598. Const
  599.   eoAll=[ ceAdd, ceDelete, ceChange, ceClone, ceDataSource ];
  600.  
  601. procedure FillTeeFunctions(AList:TStrings);
  602.  
  603. Function GetOwnerForm(AControl:TControl):TForm;
  604.  
  605. { Show the Export dialog }
  606. Procedure ChartExport(AOwner:TForm; AChart:TCustomChart);
  607.  
  608. implementation
  609.  
  610. {$R *.DFM}
  611.  
  612. uses Printers,Dialogs,PenDlg,BrushDlg,TeeGally,TeExport,TypInfo,
  613.      TeeConst,TeeLisB,Series,TeCanvas,TeeStore;
  614.  
  615. type
  616.   TChartEditSource=class
  617.   public
  618.     SelectedValueSource:String;
  619.     CBValues:TComboBox;
  620.     LabelValues:TLabel;
  621.     CBDateTime:TCheckBox;
  622.     Destructor Destroy; override;
  623.   end;
  624.  
  625.   TChartEditSources=class
  626.   public
  627.     ParentForm:TChartEditForm;
  628.     SelectedDataSource:TComponent;
  629.     SelectedXLabelsSource:String;
  630.     Values:Array[0..MaxValueSources-1] of TChartEditSource;
  631.     Constructor Create(AParent:TChartEditForm);
  632.     Destructor Destroy; override;
  633.     procedure ClearValueSources;
  634.     procedure SetSeries(TheSeries:TChartSeries);
  635.     procedure ClearCombos(EnableCombos:Boolean);
  636.     procedure SetSeriesDatabaseSource(TheSeries:TChartSeries);
  637.     procedure ClearSources;
  638.   end;
  639.  
  640. Var TheSource:TChartEditSources;
  641.  
  642. { Helper functions }
  643. Function GetOwnerForm(AControl:TControl):TForm;
  644. begin
  645.   While (AControl<>nil) and (not (AControl is TForm)) do
  646.         AControl:=AControl.Owner as TControl;
  647.   if AControl=nil then result:=nil else result:=AControl as TForm;
  648. end;
  649.  
  650. procedure FillTeeFunctions(AList:TStrings);
  651. var t:Longint;
  652. begin
  653.   AList.Clear;
  654.   AList.Add(TeeMsg_FunctionNone);
  655.   With TeeSeriesTypes do
  656.   for t:=0 to Count-1 do
  657.     With SeriesType[t] do
  658.     if (FunctionClass<>nil) and
  659.        (SeriesClass=nil) and
  660.        ( AList.IndexOfObject(TObject(FunctionClass))=-1) then
  661.           AList.InsertObject(1,Description,TObject(FunctionClass));
  662. end;
  663.  
  664. Procedure TeeExportSaveChart(ExportPanel:TCustomTeePanel; Const AFileName:String); far;
  665. begin
  666.   if ExportPanel is TCustomChart then
  667.      SaveChartToFile(TCustomChart(ExportPanel),AFileName)
  668.   else
  669.      SaveTeeToFile(ExportPanel,AFileName);
  670. end;
  671.  
  672. Procedure ChartExport(AOwner:TForm; AChart:TCustomChart);
  673. begin
  674.   With TTeeExportForm.Create(AOwner) do
  675.   try
  676.     ExportPanel:=AChart;
  677.     TeeExportSave:=TeeExportSaveChart;
  678.     try
  679.       ShowModal;
  680.     finally
  681.       TeeExportSave:=nil;
  682.     end;
  683.   finally
  684.     Free;
  685.   end;
  686. end;
  687.  
  688. { TChartEditSource }
  689. Destructor TChartEditSource.Destroy;
  690. begin
  691.   CBValues.Free;
  692.   CBValues:=nil;
  693.   LabelValues.Free;
  694.   LabelValues:=nil;
  695.   CBDateTime.Free;
  696.   CBDateTime:=nil;
  697.   SelectedValueSource:='';
  698.   inherited Destroy;
  699. end;
  700.  
  701. { TChartEditSources }
  702. Constructor TChartEditSources.Create(AParent:TChartEditForm);
  703. var t:Longint;
  704. begin
  705.   inherited Create;
  706.   ParentForm:=AParent;
  707.   for t:=0 to MaxValueSources-1 do Values[t]:=TChartEditSource.Create;
  708.   ClearValueSources;
  709. end;
  710.  
  711. procedure TChartEditSources.ClearSources;
  712. var t:Longint;
  713. begin
  714.   SelectedXLabelsSource:='';
  715.   for t:=0 to ParentForm.TheSeries.ValuesLists.Count-1 do
  716.   With Self.Values[t] do
  717.   begin
  718.     CBValues.ItemIndex:=-1;
  719.     SelectedValueSource:='';
  720.   end;
  721. end;
  722.  
  723. procedure TChartEditSources.SetSeriesDatabaseSource(TheSeries:TChartSeries);
  724. var t:Longint;
  725. begin
  726.   for t:=0 to TheSeries.ValuesLists.Count-1 do
  727.   With Self.Values[t] do
  728.   begin
  729.     CBValues.ItemIndex:=CBValues.Items.IndexOf(SelectedValueSource);
  730.     CBDateTime.Checked:=TheSeries.ValuesLists.ValueList[t].DateTime;
  731.   end;
  732. end;
  733.  
  734. procedure TChartEditSources.ClearCombos(EnableCombos:Boolean);
  735. var t:Longint;
  736. begin
  737.   for t:=0 to ParentForm.TheSeries.ValuesLists.Count-1 do
  738.   With Self.Values[t] do
  739.   begin
  740.     CBValues.Items.Clear;
  741.     CBValues.Enabled:=EnableCombos;
  742.   end;
  743. end;
  744.  
  745. procedure TChartEditSources.SetSeries(TheSeries:TChartSeries);
  746. var t:Longint;
  747. begin
  748.   With TheSeries do
  749.   begin
  750.     SelectedDataSource:=DataSource;
  751.     SelectedXLabelsSource:=XLabelsSource;
  752.     for t:=0 to MaxValueSources-1 do
  753.     begin
  754.       Values[t].Free;
  755.       Values[t]:=TChartEditSource.Create;
  756.     end;
  757.     for t:=0 to ValuesLists.Count-1 do
  758.         Values[t].SelectedValueSource:=ValuesLists.ValueList[t].ValueSource;
  759.   end;
  760. end;
  761.  
  762. procedure TChartEditSources.ClearValueSources;
  763. var t:Longint;
  764. begin
  765.   SelectedDataSource:=nil;
  766.   for t:=0 to MaxValueSources-1 do Values[t].SelectedValueSource:='';
  767.   SelectedXLabelsSource:='';
  768. end;
  769.  
  770. Destructor TChartEditSources.Destroy;
  771. var t:Longint;
  772. begin
  773.   for t:=0 to MaxValueSources-1 do Values[t].Free;
  774.   inherited Destroy;
  775. end;
  776.  
  777. { TChartEditForm }
  778. procedure TChartEditForm.SELegMarginChange(Sender: TObject);
  779. begin
  780.   if not CreatingForm then
  781.   With TheChart.Legend do
  782.   Case Alignment of
  783.     laTop,laBottom: VertMargin:=SELegMargin.Value;
  784.     laLeft,laRight: HorizMargin:=SELegMargin.Value;
  785.   end;
  786. end;
  787.  
  788. procedure TChartEditForm.cbLegendStyleChange(Sender: TObject);
  789. begin
  790.   if not CreatingForm then
  791.   TheChart.Legend.LegendStyle:=TLegendStyle(CBLegendStyle.ItemIndex);
  792. end;
  793.  
  794. Function TChartEditForm.AxisTitleOrName(Axis:TCustomChartAxis):String;
  795. Begin
  796.   result:=Axis.Title.Caption;
  797.   if result='' then
  798.   With Axis do
  799.   begin
  800.     if Horizontal then
  801.       if OtherSide then result:=TeeMsg_TopAxis
  802.                    else result:=TeeMsg_BottomAxis
  803.     else
  804.       if OtherSide then result:=TeeMsg_RightAxis
  805.                    else result:=TeeMsg_LeftAxis;
  806.   end;
  807. End;
  808.  
  809. Function TChartEditForm.GetDateTimeStepText(tmp:TDateTimeStep):String;
  810. begin
  811.   result:='';
  812.   With TAxisIncrement.Create(Self) do
  813.   try
  814.     result:=CBSteps.Items[Ord(tmp)];
  815.   finally
  816.     Free;
  817.   end;
  818. end;
  819.  
  820. Function DelphiToLocalFormat(Const Format:String):String;
  821. var t:Longint;
  822. begin
  823.   result:=Format;
  824.   for t:=1 to Length(result) do
  825.       if result[t]=',' then result[t]:=ThousandSeparator else
  826.       if result[t]='.' then result[t]:=DecimalSeparator;
  827. end;
  828.  
  829. Function LocalToDelphiFormat(Const Format:String):String;
  830. var t:Longint;
  831. begin
  832.   result:=Format;
  833.   for t:=1 to Length(result) do
  834.       if result[t]=ThousandSeparator then result[t]:=',' else
  835.       if result[t]=DecimalSeparator then result[t]:='.';
  836. end;
  837.  
  838. Procedure TChartEditForm.SetAxisPosition;
  839. begin
  840.   With TheAxis do
  841.   Begin
  842.     SEAxisPos.Value:=Round(PositionPercent);
  843.     SEAxisStart.Value:=Round(StartPosition);
  844.     SEAxisEnd.Value:=Round(EndPosition);
  845.     EnableControls(not TheAxis.IsDepthAxis,[SEAxisPos,SEAxisStart,SEAxisEnd]);
  846.   end;
  847. end;
  848.  
  849. Procedure TChartEditForm.SetAxisLabels;
  850. var tmp:String;
  851. begin  { Axis Labels  }
  852.   With TheAxis do
  853.   Begin
  854.     CBAxisLabels.Checked:=Labels;
  855.     RGAxisLabelStyle.ItemIndex:=Ord(LabelStyle);
  856.     CBLabelsOnAxis.Checked:=LabelsOnAxis;
  857.     CBRoundFirstLabel.Checked:=RoundFirstLabel;
  858.     SEAxisLabelsAngle.Value:=LabelsAngle;
  859.     SEAxisLabelSepar.Value:=LabelsSeparation;
  860.     SELabelsSize.Value:=LabelsSize;
  861.     CBMultiLine.Checked:=LabelsMultiLine;
  862.     if IsDateTime then
  863.     begin
  864.       LabelAxisFormat.Caption:=TeeMsg_DateTimeFormat;
  865.       tmp:=DateTimeFormat;
  866.       if tmp='' then tmp:=DateTimeDefaultFormat(Maximum-Minimum);
  867.       EAxisValuesFormat.Text:=tmp;
  868.     end
  869.     else
  870.     begin
  871.       LabelAxisFormat.Caption:=TeeMsg_ValuesFormat;
  872.       tmp:=AxisValuesFormat;
  873.       if tmp='' then tmp:=TeeMsg_DefValueFormat;
  874.       EAxisValuesFormat.Text:=DelphiToLocalFormat(tmp);
  875.     end;
  876.   end;
  877. end;
  878.  
  879. Procedure TChartEditForm.SetAxisTicks;
  880. begin
  881.   With TheAxis do
  882.   Begin
  883.     SEAxisTickLength.Value:=TickLength;
  884.     SEInnerTicksLength.Value:=TickInnerLength;
  885.     SEAxisMinorTickLen.Value:=MinorTickLength;
  886.     SEMinorCount.Value:=MinorTickCount;
  887.     CBTickOnLabels.Checked:=TickOnLabelsOnly;
  888.   end;
  889. end;
  890.  
  891. Procedure TChartEditForm.SetAxisTitle;
  892. begin
  893.   With TheAxis do
  894.   Begin
  895.     EAxisTitle.Text:=Title.Caption;
  896.     SEAxisTitleAngle.Value:=Title.Angle;
  897.     SEAxisTitleSize.Value:=TitleSize;
  898.   end;
  899. end;
  900.  
  901. Procedure TChartEditForm.SetAxisScales;
  902. var tmp:TDateTimeStep;
  903. Begin
  904.   CreatingForm:=True;
  905.   With TheAxis do
  906.   Begin
  907.     if IsDateTime then
  908.     begin
  909.       tmp:=FindDateTimeStep(Increment);
  910.       if ExactDateTime and (tmp<>dtNone) then
  911.          LAxisIncre.Caption:=GetDateTimeStepText(tmp)
  912.       else
  913.       if Increment<=0 then
  914.          LAxisIncre.Caption:=TimeToStr(DateTimeStep[dtOneSecond])
  915.       else
  916.       if Increment<=1 then
  917.          LAxisIncre.Caption:=TimeToStr(Increment)
  918.       else
  919.       Begin
  920.         LAxisIncre.Caption:=FloatToStr(Int(Increment));
  921.         if Frac(Increment)<>0 then
  922.            LAxisIncre.Caption:=LAxisIncre.Caption+' '+TimeToStr(Frac(Increment));
  923.       end;
  924.       if Minimum>=1 then LAxisMin.Caption:=DateTimeToStr(Minimum)
  925.                     else LAxisMin.Caption:=TimeToStr(Minimum);
  926.       if Maximum>=1 then LAxisMax.Caption:=DateTimeToStr(Maximum)
  927.                     else LAxisMax.Caption:=TimeToStr(Maximum);
  928.     end
  929.     else
  930.     begin
  931.       LAxisIncre.Caption:=FormatFloat(AxisValuesFormat,Increment);
  932.       LAxisMin.Caption:=FormatFloat(AxisValuesFormat,Minimum);
  933.       LAxisMax.Caption:=FormatFloat(AxisValuesFormat,Maximum);
  934.     end;
  935.     CBAutomatic.Checked:=Automatic;
  936.     CBAutoMax.Checked:=AutomaticMaximum;
  937.     CBAutoMin.Checked:=AutomaticMinimum;
  938.     CBLogarithmic.Checked:=Logarithmic;
  939.     CBInverted.Checked:=Inverted;
  940.     CBLogarithmic.Enabled:=not IsDepthAxis;
  941.     { enable controls... }
  942.     BAxisMax.Enabled:=(not Automatic) and (not AutomaticMaximum);
  943.     BAxisMin.Enabled:=(not Automatic) and (not AutomaticMinimum);
  944.     EnableControls(not Automatic,[CBAutoMax,CBAutoMin]);
  945.   end;
  946.   CreatingForm:=False;
  947. end;
  948.  
  949. procedure TChartEditForm.SpinEdit2Change(Sender: TObject);
  950. begin
  951.   if not CreatingForm then TheChart.Legend.ColorWidth:=SELegColWi.Value;
  952. end;
  953.  
  954. Function TChartEditForm.SelectedTitle:TChartTitle;
  955. begin
  956.   if CBTitles.ItemIndex=0 then result:=TheChart.Title
  957.                           else result:=TheChart.Foot;
  958. end;
  959.  
  960. Function TChartEditForm.SelectedWall:TChartWall;
  961. begin
  962.   Case TabSubWalls.PageIndex of
  963.     0: result:=TheChart.LeftWall;
  964.     1: result:=TheChart.BottomWall;
  965.   else result:=TheChart.BackWall;
  966.   end;
  967. end;
  968.  
  969. procedure TChartEditForm.BTitFontClick(Sender: TObject);
  970. begin
  971.   With SelectedTitle do
  972.   Begin
  973.     Font:=InternalEditFont(Self,Font);
  974.     MTitle.Font:=Font;
  975.     if MTitle.Font.Color=clWhite then MTitle.Color:=clDkGray
  976.                                  else MTitle.Color:=clWhite;
  977.   end;
  978. end;
  979.  
  980. procedure TChartEditForm.BColGridClick(Sender: TObject);
  981. begin
  982.   EditChartPen(Self,TheAxis.Grid);
  983. end;
  984.  
  985. procedure TChartEditForm.RGHorizAxisClick(Sender: TObject);
  986. begin
  987.   Case RGHorizAxis.ItemIndex of
  988.     0: TheSeries.HorizAxis:=aTopAxis;
  989.     1: TheSeries.HorizAxis:=aBottomAxis;
  990.     2: TheSeries.HorizAxis:=aBothHorizAxis;
  991.   end;
  992. end;
  993.  
  994. Procedure TChartEditForm.EnableLegendMarginControls;
  995. begin
  996.   With TheChart.Legend do
  997.   Case Alignment of
  998.     laTop,laBottom: SELegMargin.Value:=VertMargin;
  999.     laLeft,laRight: SELegMargin.Value:=HorizMargin;
  1000.   end;
  1001. end;
  1002.  
  1003. Function GetEditingCaption(AChart:TCustomChart):String;
  1004. begin
  1005.   FmtStr(result,TeeMsg_Editing,[AChart.Name]);
  1006. end;
  1007.  
  1008. procedure TChartEditForm.BEditSeriesClick;
  1009. var tmp:Boolean;
  1010. begin
  1011.   if LBSeries.ItemIndex<>-1 then
  1012.   begin
  1013.     MainPage.PageIndex:=1;
  1014.     PageControlSeries.PageIndex:=0;
  1015.     MainPageChange(Self,MainPage.PageIndex,tmp);
  1016.   end;
  1017. end;
  1018.  
  1019. procedure TChartEditForm.FormShow(Sender: TObject);
  1020. begin
  1021.   Screen.Cursor:=crDefault;
  1022.   CreatingForm:=True;
  1023.   if Caption='' then Caption:=GetEditingCaption(TheChart);
  1024.   With TheChart do
  1025.   begin
  1026.     if not Assigned(TheAxis) then TheAxis:=LeftAxis;
  1027.     if TheAxis=LeftAxis   then RGWhatAxis.ItemIndex:=0    else
  1028.     if TheAxis=RightAxis  then RGWhatAxis.ItemIndex:=1    else
  1029.     if TheAxis=TopAxis    then RGWhatAxis.ItemIndex:=2    else
  1030.     if TheAxis=BottomAxis then RGWhatAxis.ItemIndex:=3    else
  1031.     if TheAxis=DepthAxis  then RGWhatAxis.ItemIndex:=4;
  1032.     CBTitles.ItemIndex:=0;
  1033.     if Assigned(TheTitle) then
  1034.     begin
  1035.       if TheTitle=Foot then CBTitles.ItemIndex:=1;
  1036.     end
  1037.     else
  1038.     if Assigned(TheWall) then
  1039.        if TheWall=LeftWall then TabSubWalls.PageIndex:=0 else
  1040.        if TheWall=BottomWall then TabSubWalls.PageIndex:=1 else
  1041.           TabSubWalls.PageIndex:=2;
  1042.   end;
  1043.   if TheActivePageIndex<>-1 then Notebook1.PageIndex:=TheActivePageIndex;
  1044.   CreatingForm:=False;
  1045. {  TabDataSource.TabVisible:=ceDataSource in EditorOptions;}
  1046.   FillSeries(TheEditSeries);
  1047.   if Assigned(TheEditSeries) then BEditSeriesClick;
  1048. end;
  1049.  
  1050. procedure TChartEditForm.SpinEdit9Change(Sender: TObject);
  1051. begin
  1052.   if not CreatingForm then TheChart.Chart3DPercent:=SE3D.Value;
  1053. end;
  1054.  
  1055. procedure TChartEditForm.SETopLegPosChange(Sender: TObject);
  1056. begin
  1057.   if not CreatingForm then TheChart.Legend.TopPos:=SETopLegPos.Value;
  1058. end;
  1059.  
  1060. procedure TChartEditForm.RGBevelInClick(Sender: TObject);
  1061. begin
  1062.   if not CreatingForm then
  1063.      if TheChart.BevelInner<>TPanelBevel(RGBevelIn.ItemIndex) then
  1064.         TheChart.BevelInner:=TPanelBevel(RGBevelIn.ItemIndex);
  1065. end;
  1066.  
  1067. procedure TChartEditForm.RGBevelOutClick(Sender: TObject);
  1068. begin
  1069.   if not CreatingForm then
  1070.      if TheChart.BevelOuter<>TPanelBevel(RGBevelOut.ItemIndex) then
  1071.         TheChart.BevelOuter:=TPanelBevel(RGBevelOut.ItemIndex);
  1072. end;
  1073.  
  1074. procedure TChartEditForm.CBPanelBorderClick(Sender: TObject);
  1075. begin
  1076.   if not CreatingForm then
  1077.   if CBPanelBorder.Checked then
  1078.      TheChart.BorderStyle:=bsSingle
  1079.   else
  1080.      TheChart.BorderStyle:=bsNone;
  1081. end;
  1082.  
  1083. procedure TChartEditForm.SEPanelWiChange(Sender: TObject);
  1084. var tmp:Longint;
  1085. begin
  1086.   if not CreatingForm then
  1087.   begin
  1088.     tmp:=SEPanelWi.Value;
  1089.     if (tmp>=0) and (tmp<=100) then
  1090.     begin
  1091.        if TheChart.BevelWidth<>tmp then
  1092.           TheChart.BevelWidth:=tmp;
  1093.     end;
  1094.   end;
  1095. end;
  1096.  
  1097. procedure TChartEditForm.RGWhatAxisClick(Sender: TObject);
  1098. var tmp:Boolean;
  1099. begin
  1100.   if not CreatingForm then
  1101.   Begin
  1102.     With TheChart do
  1103.     Case TRadioGroup(Sender).ItemIndex of
  1104.       0: TheAxis:=LeftAxis;
  1105.       1: TheAxis:=RightAxis;
  1106.       2: TheAxis:=TopAxis;
  1107.       3: TheAxis:=BottomAxis;
  1108.       4: TheAxis:=DepthAxis;
  1109.     end;
  1110.     CBAxisVisible.Checked:=TheAxis.Visible;
  1111.     PageControlAxisChange(Self,PageControlAxis.PageIndex,tmp);
  1112.   end;
  1113. end;
  1114.  
  1115. procedure TChartEditForm.CBAxisVisibleClick(Sender: TObject);
  1116. begin
  1117.   if not CreatingForm then
  1118.   TheAxis.Visible:=CBAxisVisible.Checked;
  1119. end;
  1120.  
  1121. procedure TChartEditForm.SEAxisTickLengthChange(Sender: TObject);
  1122. begin
  1123.   if not CreatingForm then
  1124.   if SEAxisTickLength.Text<>'' then
  1125.   TheAxis.TickLength:=SEAxisTickLength.Value;
  1126. end;
  1127.  
  1128. procedure TChartEditForm.BLegFontClick(Sender: TObject);
  1129. begin
  1130.   With TheChart.Legend do Font:=InternalEditFont(Self,Font);
  1131. end;
  1132.  
  1133. procedure TChartEditForm.BPrintClick(Sender: TObject);
  1134. begin
  1135.   ChartPreview(Self,TheChart);
  1136. end;
  1137.  
  1138. procedure TChartEditForm.BLegColorClick(Sender: TObject);
  1139. begin
  1140.   with TheChart.Legend do Color:=EditColor(Self,Color);
  1141. end;
  1142.  
  1143. procedure TChartEditForm.BMarksBackColorClick(Sender: TObject);
  1144. begin
  1145.   With TheSeries.Marks do BackColor:=EditColor(Self,BackColor);
  1146.   CBTransparent.Checked:=False;
  1147. end;
  1148.  
  1149. procedure TChartEditForm.CBAutomaticClick(Sender: TObject);
  1150. begin
  1151.   if not CreatingForm then
  1152.   With TheAxis do
  1153.   Begin
  1154.     Automatic:=CBAutomatic.Checked;
  1155.     if Automatic then AdjustMaxMin
  1156.     else
  1157.     begin
  1158.       AutomaticMaximum:=False;
  1159.       AutomaticMinimum:=False;
  1160.     end;
  1161.     SetAxisScales;
  1162.   end;
  1163. end;
  1164.  
  1165. procedure TChartEditForm.CBLegStyleChange(Sender: TObject);
  1166. begin
  1167.   if not CreatingForm then TheChart.Legend.TextStyle:=TLegendTextStyle(CBLegStyle.ItemIndex);
  1168. end;
  1169.  
  1170. procedure TChartEditForm.BBackColClick(Sender: TObject);
  1171. begin
  1172.   With TheChart do BackColor:=EditColor(Self,BackColor);
  1173. end;
  1174.  
  1175. procedure TChartEditForm.CBShowLegClick(Sender: TObject);
  1176. begin
  1177.   if not CreatingForm then TheChart.Legend.Visible:=CBShowLeg.Checked;
  1178. end;
  1179.  
  1180. procedure TChartEditForm.CBAllowZoomClick(Sender: TObject);
  1181. begin
  1182.   if not CreatingForm then TheChart.AllowZoom:=CBAllowZoom.Checked;
  1183. end;
  1184.  
  1185. procedure TChartEditForm.CBClipPointsClick(Sender: TObject);
  1186. begin
  1187.   if not CreatingForm then TheChart.ClipPoints:=CBClipPoints.Checked;
  1188. end;
  1189.  
  1190. procedure TChartEditForm.CBTitleVisibleClick(Sender: TObject);
  1191. begin
  1192.   if not CreatingForm then SelectedTitle.Visible:=CBTitleVisible.Checked;
  1193. end;
  1194.  
  1195. procedure TChartEditForm.EAxisTitleChange(Sender: TObject);
  1196. begin
  1197.   if not CreatingForm then TheAxis.Title.Caption:=EAxisTitle.Text;
  1198. end;
  1199.  
  1200. procedure TChartEditForm.BChartFrameClick(Sender: TObject);
  1201. begin
  1202.   EditChartPen(Self,TheChart.Frame);
  1203. end;
  1204.  
  1205. procedure TChartEditForm.BLegendFrameClick(Sender: TObject);
  1206. begin
  1207.   EditChartPen(Self,TheChart.Legend.Frame);
  1208. end;
  1209.  
  1210. procedure TChartEditForm.BTitleFontClick(Sender: TObject);
  1211. begin
  1212.   With TheAxis.Title do Font:=InternalEditFont(Self,Font);
  1213. end;
  1214.  
  1215. procedure TChartEditForm.FormCreate(Sender: TObject);
  1216. begin
  1217.   TheActivePageIndex:=-1;
  1218.   NumSeriesForms:=0;
  1219.   EditorOptions:=[ceAdd,ceDelete,ceChange,ceClone,ceDataSource,ceTitle];
  1220.   OnChartFillFields:=nil;
  1221.   OnChartIsDateTimeSource:=nil;
  1222.   OnChartIsValidComponentSource:=nil;
  1223.   TheAxis  :=nil;
  1224.   TheSeries:=nil;
  1225.   TheEditSeries:=nil;
  1226.   TheChart :=nil;
  1227.   TheTitle :=nil;
  1228.   TheWall  :=nil;
  1229.   ComingFromDoubleClick:=False;
  1230.   TheSource:=TChartEditSources.Create(Self);
  1231.   MainPage.PageIndex:=0;
  1232.   NoteBook1.PageIndex:=0;
  1233.   PageControlSeries.PageIndex:=0;
  1234. end;
  1235.  
  1236. Function EqualStrings(A,B:TStrings):Boolean;
  1237. var t:Longint;
  1238. begin
  1239.   result:=A.Count=B.Count;
  1240.   if result then
  1241.   begin
  1242.     for t:=0 to A.Count-1 do
  1243.     begin
  1244.       result:=A[t]=B[t];
  1245.       if not result then break;
  1246.     end;
  1247.   end;
  1248. end;
  1249.  
  1250. procedure TChartEditForm.MTitleChange(Sender: TObject);
  1251. begin
  1252.   if not CreatingForm then
  1253.   With SelectedTitle do
  1254.   if not EqualStrings(Text,MTitle.Lines) then Text:=MTitle.Lines;
  1255. end;
  1256.  
  1257. procedure TChartEditForm.BAxisMaxClick(Sender: TObject);
  1258. begin
  1259.   With TAxisMaxMin.Create(Self) do
  1260.   try
  1261.     Caption:=TeeMsg_Maximum+' '+AxisTitleOrName(TheAxis);
  1262.     IsDateTime:=TheAxis.IsDateTime;
  1263.     MaxMin:=TheAxis.Maximum;
  1264.     if ShowModal=mrOk then
  1265.     Begin
  1266.       TheAxis.Maximum:=MaxMin;
  1267.       CBAutoMax.Checked:=False;
  1268.       SetAxisScales;
  1269.     end;
  1270.   finally
  1271.     Free;
  1272.   end;
  1273. end;
  1274.  
  1275. procedure TChartEditForm.BAxisMinClick(Sender: TObject);
  1276. begin
  1277.   With TAxisMaxMin.Create(Self) do
  1278.   try
  1279.     Caption:=TeeMsg_Minimum+' '+AxisTitleOrName(TheAxis);
  1280.     IsDateTime:=TheAxis.IsDateTime;
  1281.     MaxMin:=TheAxis.Minimum;
  1282.     if ShowModal=mrOk then
  1283.     Begin
  1284.       TheAxis.Minimum:=MaxMin;
  1285.       CBAutoMin.Checked:=False;
  1286.       SetAxisScales;
  1287.     end;
  1288.   finally
  1289.     Free;
  1290.   end;
  1291. end;
  1292.  
  1293. procedure TChartEditForm.BAxisIncreClick(Sender: TObject);
  1294. begin
  1295.   With TAxisIncrement.Create(Self) do
  1296.   try
  1297.     Caption:=Format(TeeMsg_DesiredIncrement,[AxisTitleOrName(TheAxis)]);
  1298.     IsDateTime  := TheAxis.IsDateTime;
  1299.     IsExact     := TheAxis.ExactDateTime;
  1300.     Increment   := TheAxis.Increment;
  1301.     IStep       := FindDateTimeStep(Increment);
  1302.     if ShowModal=mrOk then
  1303.     Begin
  1304.       TheAxis.Increment:=Increment;
  1305.       TheAxis.ExactDateTime:=IsExact;
  1306.       SetAxisScales;
  1307.     end;
  1308.   finally
  1309.     Free;
  1310.   end;
  1311. end;
  1312.  
  1313. procedure TChartEditForm.BPanelColorClick(Sender: TObject);
  1314. begin
  1315.   With TheChart do Color:=EditColor(Self,Color);
  1316. end;
  1317.  
  1318. procedure TChartEditForm.CBLogarithmicClick(Sender: TObject);
  1319. begin
  1320.   if not CreatingForm then
  1321.   try
  1322.     TheAxis.Logarithmic:=CBLogarithmic.Checked;
  1323.   except
  1324.     on AxisException do
  1325.     Begin
  1326.       TheAxis.Logarithmic:=False;
  1327.       CBLogarithmic.Checked:=False;
  1328.       Raise;
  1329.     end;
  1330.   end;
  1331. end;
  1332.  
  1333. procedure TChartEditForm.BInnerTicksClick(Sender: TObject);
  1334. begin
  1335.   EditChartPen(Self,TheAxis.TicksInner);
  1336. end;
  1337.  
  1338. procedure TChartEditForm.SEInnerTicksLengthChange(Sender: TObject);
  1339. begin
  1340.   if not CreatingForm then
  1341.   if SEInnerTicksLength.Text<>'' then
  1342.   TheAxis.TickInnerLength:=SEInnerTicksLength.Value;
  1343. end;
  1344.  
  1345. procedure TChartEditForm.ButtonNextClick(Sender: TObject);
  1346. begin
  1347.   TheChart.NextPage;  { <-- goto next chart page }
  1348.   TheChartPageChange(Self);
  1349. end;
  1350.  
  1351. procedure TChartEditForm.ButtonPreviousClick(Sender: TObject);
  1352. begin
  1353.   TheChart.PreviousPage;  { <-- goto next chart page }
  1354.   TheChartPageChange(Self);
  1355. end;
  1356.  
  1357. procedure TChartEditForm.TheChartPageChange(Sender: TObject);
  1358. begin
  1359.   { show the current page number and the total number of pages }
  1360.   { (like a report) }
  1361.   LabelPages.Caption:=IntToStr(TheChart.Page)+'/'+IntToStr(TheChart.NumPages);
  1362.   { enable or disable buttons }
  1363.   ButtonPrevious.Enabled:=TheChart.Page > 1;
  1364.   BFirstPage.Enabled:=ButtonPrevious.Enabled;
  1365.   ButtonNext.Enabled:=TheChart.Page < TheChart.NumPages;
  1366.   BLastPage.Enabled:=ButtonNext.Enabled;
  1367. end;
  1368.  
  1369. procedure TChartEditForm.SEPointsPerPageChange(Sender: TObject);
  1370. begin
  1371.   if SEPointsPerPage.Text='' then
  1372.      TheChart.MaxPointsPerPage:=0
  1373.   else
  1374.      TheChart.MaxPointsPerPage:=SEPointsPerPage.Value;
  1375.   TheChartPageChange(TheChart); { <-- repaint page / number of pages }
  1376. end;
  1377.  
  1378. procedure TChartEditForm.CBScaleLastClick(Sender: TObject);
  1379. begin
  1380.   if not CreatingForm then TheChart.ScaleLastPage:=CBScaleLast.Checked;
  1381. end;
  1382.  
  1383. procedure TChartEditForm.BGradientStartClick(Sender: TObject);
  1384. begin
  1385.   TheChart.Gradient.StartColor:=EditColor(Self,TheChart.Gradient.StartColor);
  1386.   RepaintGradientColors;
  1387. end;
  1388.  
  1389. procedure TChartEditForm.RepaintGradientColors;
  1390. Begin
  1391.   With PaintBox1 do
  1392.   Begin
  1393.     Pen.Style:=psSolid;
  1394.     Pen.Color:=clBlack;
  1395.     Brush.Style:=bsSolid;
  1396.     Brush.Color:=TheChart.Gradient.StartColor;
  1397.   end;
  1398.   With PaintBox2 do
  1399.   Begin
  1400.     Pen.Style:=psSolid;
  1401.     Pen.Color:=clBlack;
  1402.     Brush.Style:=bsSolid;
  1403.     Brush.Color:=TheChart.Gradient.EndColor;
  1404.   end;
  1405. End;
  1406.  
  1407. procedure TChartEditForm.BGradientEndClick(Sender: TObject);
  1408. begin
  1409.   TheChart.Gradient.EndColor:=EditColor(Self,TheChart.Gradient.EndColor);
  1410.   RepaintGradientColors;
  1411. end;
  1412.  
  1413. procedure TChartEditForm.RGGradientDirectionClick(Sender: TObject);
  1414. begin
  1415.   TheChart.Gradient.Direction:=TGradientDirection(RGGradientDirection.ItemIndex);
  1416. end;
  1417.  
  1418. procedure TChartEditForm.CheckGradientVisible;
  1419. Begin
  1420.   RGGradientDirection.ItemIndex:=Ord(TheChart.Gradient.Direction);
  1421.   EnableControls(TheChart.Gradient.Visible,[ RGGradientDirection,
  1422.                                              BGradientStart,
  1423.                                              BGradientEnd,
  1424.                                              PaintBox1,
  1425.                                              PaintBox2]);
  1426.   RepaintGradientColors;
  1427. end;
  1428.  
  1429. procedure TChartEditForm.CBGradientVisibleClick(Sender: TObject);
  1430. begin
  1431.   if not CreatingForm then
  1432.      TheChart.Gradient.Visible:=CBGradientVisible.Checked;
  1433.   CheckGradientVisible;
  1434. end;
  1435.  
  1436. procedure TChartEditForm.BLastPageClick(Sender: TObject);
  1437. begin
  1438.   TheChart.Page:=TheChart.NumPages;  { <-- goto Last chart page }
  1439.   TheChartPageChange(Self);
  1440. end;
  1441.  
  1442. procedure TChartEditForm.BFirstPageClick(Sender: TObject);
  1443. begin
  1444.   TheChart.Page:=1;  { <-- goto first chart page }
  1445.   TheChartPageChange(Self);
  1446. end;
  1447.  
  1448. procedure TChartEditForm.CBAnimatedZoomClick(Sender: TObject);
  1449. begin
  1450.   if not CreatingForm then TheChart.AnimatedZoom:=CBAnimatedZoom.Checked;
  1451. end;
  1452.  
  1453. procedure TChartEditForm.CBResizeChartClick(Sender: TObject);
  1454. begin
  1455.   if not CreatingForm then TheChart.Legend.ResizeChart:=CBResizeChart.Checked;
  1456. end;
  1457.  
  1458. procedure TChartEditForm.BTitleFrameClick(Sender: TObject);
  1459. begin
  1460.   EditChartPen(Self,SelectedTitle.Frame);
  1461. end;
  1462.  
  1463. procedure TChartEditForm.CBFootAdjustClick(Sender: TObject);
  1464. begin
  1465.   TheChart.Foot.AdjustFrame:=TCheckBox(Sender).Checked;
  1466. end;
  1467.  
  1468. procedure TChartEditForm.CBTitleAdjustClick(Sender: TObject);
  1469. begin
  1470.   SelectedTitle.AdjustFrame:=TCheckBox(Sender).Checked;
  1471. end;
  1472.  
  1473. procedure TChartEditForm.BTitleBrushClick(Sender: TObject);
  1474. begin
  1475.   EditChartBrush(Self,SelectedTitle.Brush);
  1476. end;
  1477.  
  1478. procedure TChartEditForm.BMinorTicksClick(Sender: TObject);
  1479. begin
  1480.   EditChartPen(Self,TheAxis.MinorTicks);
  1481. end;
  1482.  
  1483. procedure TChartEditForm.SEAxisMinorTickLenChange(Sender: TObject);
  1484. begin
  1485.   if not CreatingForm then
  1486.   if SEAxisMinorTickLen.Text<>'' then
  1487.   TheAxis.MinorTickLength:=SEAxisMinorTickLen.Value;
  1488. end;
  1489.  
  1490. procedure TChartEditForm.SEMinorCountChange(Sender: TObject);
  1491. begin
  1492.   if not CreatingForm then
  1493.   if SEMinorCount.Text<>'' then
  1494.   TheAxis.MinorTickCount:=SEMinorCount.Value;
  1495. end;
  1496.  
  1497. procedure TChartEditForm.SEPanelBorChange(Sender: TObject);
  1498. var tmp:Longint;
  1499. begin
  1500.   if not CreatingForm then
  1501.   begin
  1502.     tmp:=SEPanelBor.Value;
  1503.     if (tmp>=0) and (tmp<=100) then
  1504.     begin
  1505.       if TheChart.BorderWidth<>tmp then
  1506.          TheChart.BorderWidth:=tmp;
  1507.     end;
  1508.   end;
  1509. end;
  1510.  
  1511. procedure TChartEditForm.CBShowAxisClick(Sender: TObject);
  1512. begin
  1513.   if not CreatingForm then TheChart.AxisVisible:= TCheckBox(Sender).Checked;
  1514. end;
  1515.  
  1516. procedure TChartEditForm.CBAutoMaxClick(Sender: TObject);
  1517. begin
  1518.   if not CreatingForm then
  1519.   Begin
  1520.     TheAxis.AutomaticMaximum:=CBAutoMax.Checked;
  1521.     TheAxis.AdjustMaxMin;
  1522.     SetAxisScales;
  1523.   end;
  1524. end;
  1525.  
  1526. procedure TChartEditForm.CBAutoMinClick(Sender: TObject);
  1527. begin
  1528.   if not CreatingForm then
  1529.   Begin
  1530.     TheAxis.AutomaticMinimum:=CBAutoMin.Checked;
  1531.     TheAxis.AdjustMaxMin;
  1532.     SetAxisScales;
  1533.   end;
  1534. end;
  1535.  
  1536. procedure TChartEditForm.CBInvertedClick(Sender: TObject);
  1537. begin
  1538.   if not CreatingForm then TheAxis.Inverted:=CBInverted.Checked;
  1539. end;
  1540.  
  1541. procedure TChartEditForm.PaintBox1MouseUp(Sender: TObject;
  1542.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1543. begin
  1544.   BGradientStartClick(Self);
  1545. end;
  1546.  
  1547. procedure TChartEditForm.PaintBox2MouseUp(Sender: TObject;
  1548.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1549. begin
  1550.   BGradientEndClick(Self);
  1551. end;
  1552.  
  1553. procedure TChartEditForm.CBLegendInvertedClick(Sender: TObject);
  1554. begin
  1555.   if not CreatingForm then TheChart.Legend.Inverted:=CBLegendInverted.Checked;
  1556. end;
  1557.  
  1558. procedure TChartEditForm.BLegShadowColClick(Sender: TObject);
  1559. begin
  1560.   with TChartLegend(TheChart.Legend) do ShadowColor:=EditColor(Self,ShadowColor);
  1561. end;
  1562.  
  1563. procedure TChartEditForm.SELegShadowSizeChange(Sender: TObject);
  1564. begin
  1565.   if not CreatingForm then
  1566.      TChartLegend(TheChart.Legend).ShadowSize:=SELegShadowSize.Value;
  1567. end;
  1568.  
  1569. procedure TChartEditForm.RGBitmapClick(Sender: TObject);
  1570. begin
  1571.   TheChart.BackImageMode:=TTeeBackImageMode(RGBitmap.ItemIndex);
  1572. end;
  1573.  
  1574. procedure TChartEditForm.SEAxisTitleAngleChange(Sender: TObject);
  1575. begin
  1576.   if not CreatingForm then
  1577.   if SEAxisTitleAngle.Text<>'' then
  1578.   TheAxis.Title.Angle:=SEAxisTitleAngle.Value;
  1579. end;
  1580.  
  1581. procedure TChartEditForm.SEAxisTitleSizeChange(Sender: TObject);
  1582. begin
  1583.   if not CreatingForm then
  1584.   if SEAxisTitleSize.Text<>'' then
  1585.   TheAxis.TitleSize:=SEAxisTitleSize.Value;
  1586. end;
  1587.  
  1588. procedure TChartEditForm.CBAxisLabelsClick(Sender: TObject);
  1589. begin
  1590.   if not CreatingForm then TheAxis.Labels:=CBAxisLabels.Checked;
  1591. end;
  1592.  
  1593. procedure TChartEditForm.SEAxisLabelsAngleChange(Sender: TObject);
  1594. begin
  1595.   if not CreatingForm then
  1596.   if SEAxisLabelsAngle.Text<>'' then
  1597.   TheAxis.LabelsAngle:=SEAxisLabelsAngle.Value;
  1598. end;
  1599.  
  1600. procedure TChartEditForm.RGAxisLabelStyleClick(Sender: TObject);
  1601. begin
  1602.   if not CreatingForm then
  1603.   TheAxis.LabelStyle:=TAxisLabelStyle(RGAxisLabelStyle.ItemIndex);
  1604. end;
  1605.  
  1606. procedure TChartEditForm.SELabelsSizeChange(Sender: TObject);
  1607. begin
  1608.   if not CreatingForm then
  1609.   if SELabelsSize.Text<>'' then
  1610.   TheAxis.LabelsSize:=SELabelsSize.Value;
  1611. end;
  1612.  
  1613. procedure TChartEditForm.CBLabelsOnAxisClick(Sender: TObject);
  1614. begin
  1615.   if not CreatingForm then
  1616.   TheAxis.LabelsOnAxis:=CBLabelsOnAxis.Checked;
  1617. end;
  1618.  
  1619. procedure TChartEditForm.SEAxisLabelSeparChange(Sender: TObject);
  1620. begin
  1621.   if not CreatingForm then
  1622.   if SEAxisLabelSepar.Text<>'' then
  1623.   TheAxis.LabelsSeparation:=SEAxisLabelSepar.Value;
  1624. end;
  1625.  
  1626. procedure TChartEditForm.CBRoundFirstLabelClick(Sender: TObject);
  1627. begin
  1628.   if not CreatingForm then
  1629.      TheAxis.RoundFirstLabel:=CBRoundFirstLabel.Checked;
  1630. end;
  1631.  
  1632. procedure TChartEditForm.EAxisValuesFormatChange(Sender: TObject);
  1633. begin
  1634.   if not CreatingForm then
  1635.   With TheAxis do
  1636.   if IsDateTime then
  1637.      DateTimeFormat:=EAxisValuesFormat.Text
  1638.   else
  1639.      AxisValuesFormat:=LocalToDelphiFormat(EAxisValuesFormat.Text);
  1640. end;
  1641.  
  1642. procedure TChartEditForm.BitBtn2Click(Sender: TObject);
  1643. begin
  1644.   With TheAxis do LabelsFont:=InternalEditFont(Self,LabelsFont);
  1645. end;
  1646.  
  1647. procedure TChartEditForm.CBView3dWallsClick(Sender: TObject);
  1648. begin
  1649.   TheChart.View3dWalls:=CBView3dWalls.Checked;
  1650.   TabSubWalls.Enabled:=TheChart.View3dWalls;
  1651. end;
  1652.  
  1653. procedure TChartEditForm.BWallPenClick(Sender: TObject);
  1654. begin
  1655.   EditChartPen(Self,SelectedWall.Pen);
  1656. end;
  1657.  
  1658. procedure TChartEditForm.BWallBrushClick(Sender: TObject);
  1659. begin
  1660.   EditChartBrush(Self,SelectedWall.Brush);
  1661. end;
  1662.  
  1663. procedure TChartEditForm.BWallColorClick(Sender: TObject);
  1664. begin
  1665.   With SelectedWall do Color:=EditColor(Self,Color);
  1666.   RefreshWallColorShape(SelectedWall);
  1667. end;
  1668.  
  1669. procedure TChartEditForm.BBottomWallPenClick(Sender: TObject);
  1670. begin
  1671.   EditChartPen(Self,TheChart.BottomWall.Pen);
  1672. end;
  1673.  
  1674. procedure TChartEditForm.BBottomWallBrushClick(Sender: TObject);
  1675. begin
  1676.   EditChartBrush(Self,TheChart.BottomWall.Brush);
  1677. end;
  1678.  
  1679. procedure TChartEditForm.SEWallSizeChange(Sender: TObject);
  1680. begin
  1681.   With Sender as TSpinEdit do
  1682.   if Text<>'' then
  1683.   begin
  1684.     SelectedWall.Size:=Value;
  1685.     RefreshWallDark(SelectedWall);
  1686.   end;
  1687. end;
  1688.  
  1689. procedure TChartEditForm.EValueformatChange(Sender: TObject);
  1690. begin
  1691.   TheSeries.ValueFormat:=LocalToDelphiFormat(EValueFormat.Text);
  1692. end;
  1693.  
  1694. procedure TChartEditForm.EPercentFormatChange(Sender: TObject);
  1695. begin
  1696.   TheSeries.PercentFormat:=LocalToDelphiFormat(EPercentFormat.Text);
  1697. end;
  1698.  
  1699. procedure TChartEditForm.SetTabSeriesMarks;
  1700. begin
  1701.   With TheSeries.Marks do
  1702.   begin
  1703.     RGMarkStyle.ItemIndex  :=Ord(Style);
  1704.     CBMarksVisible.Checked :=Visible;
  1705.     SEArrowLength.Value    :=ArrowLength;
  1706.     CBTransparent.Checked  :=Transparent;
  1707.     CBMarkClip.Checked     :=Clip;
  1708.   end;
  1709. end;
  1710.  
  1711. procedure TChartEditForm.SetTabSeriesDatabase;
  1712. var t:Longint;
  1713.     tmpName:String;
  1714. begin
  1715.   GroupFields.Visible:=False;
  1716.   FillSourceDatasets;
  1717.   TheSource.SetSeries(TheSeries);
  1718.   With TheSeries,TheSource do
  1719.   begin
  1720.     for t:=0 to ValuesLists.Count-1 do
  1721.     With TheSource.Values[t] do
  1722.     begin
  1723.       tmpName:=ValuesLists.ValueList[t].Name;
  1724.       CBValues:=TComboBox.Create(ParentForm);
  1725.       With CBValues do
  1726.       begin
  1727.         Parent:=ParentForm.GroupFields;
  1728.         Left:=ParentForm.CBLabelsField.Left;
  1729.         Style:=csDropDown;
  1730.         Width:=ParentForm.CBLabelsField.Width;
  1731.         Top:=2+ParentForm.CBLabelsField.Top+ParentForm.CBLabelsField.Height+(25*t+1);
  1732.         OnChange:=ParentForm.CBValuesChange;
  1733.         Tag:=t;
  1734.         Visible:=tmpName<>'';
  1735.       end;
  1736.       LabelValues:=TLabel.Create(ParentForm);
  1737.       With LabelValues do
  1738.       begin
  1739.         Alignment:=taRightJustify;
  1740.         Parent:=ParentForm.GroupFields;
  1741.         Top:=CBValues.Top+4;
  1742.         AutoSize:=False;
  1743.         Left:=ParentForm.LabelLabels.Left;
  1744.         Width:=ParentForm.LabelLabels.Width;
  1745.         Caption:=tmpName+':';
  1746.         Visible:=tmpName<>'';
  1747.       end;
  1748.       CBDateTime:=TCheckBox.Create(ParentForm);
  1749.       With CBDateTime do
  1750.       begin
  1751.         Parent:=ParentForm.GroupFields;
  1752.         Left:=ParentForm.CBLabelsField.Left+ParentForm.CBLabelsField.Width+6;
  1753.         Width:=90;
  1754.         Top:=CBValues.Top;
  1755.         Caption:=TeeMsg_DateTime;
  1756.         Tag:=t;
  1757.         Visible:=tmpName<>'';
  1758.         OnClick:=ParentForm.CBDateTimeClick;
  1759.       end;
  1760.       SelectedValueSource:=ValuesLists.ValueList[t].ValueSource;
  1761.     end;
  1762.   end;
  1763.   TheSource.SetSeriesDatabaseSource(TheSeries);
  1764.   SetCurrentDataSource;
  1765.   SetSelectedSourceDatabase;
  1766.   GroupFields.Visible:=True;
  1767.   ApplyChangesDataSet:=False;
  1768. end;
  1769.  
  1770. procedure TChartEditForm.SetTabSeriesFunctions;
  1771. var t:Longint;
  1772.     tmpSeries:TChartSeries;
  1773. begin
  1774.   FillSourceSeries;
  1775.   TheSource.SetSeries(TheSeries);
  1776.   LBSelectedSeries.Items.BeginUpdate;
  1777.   LBSelectedSeries.Clear;
  1778.   if (TheSeries.DataSource<>nil) then
  1779.   for t:=0 to TheSeries.DataSources.Count-1 do
  1780.   begin
  1781.     if TComponent(TheSeries.DataSources[t]) is TChartSeries then
  1782.     begin
  1783.       tmpSeries:=TChartSeries(TheSeries.DataSources[t]);
  1784.       With tmpSeries do
  1785.            if Title<>'' then LBSelectedSeries.Items.AddObject(Title,tmpSeries)
  1786.                         else LBSelectedSeries.Items.AddObject(Name,tmpSeries);
  1787.     end;
  1788.   end;
  1789.   LBSelectedSeries.Items.EndUpdate;
  1790.   With CBFunctions do
  1791.   if TheSeries.FunctionType<>nil then
  1792.      ItemIndex:=Items.IndexOfObject(TObject(TTeeFunction(TheSeries.FunctionType).ClassType))
  1793.   else
  1794.      ItemIndex:=0;
  1795.   ApplyChangesFunction:=False;
  1796.   EnableListButtons;
  1797. end;
  1798.  
  1799. procedure TChartEditForm.SetTabSeriesDataSource;
  1800. begin
  1801.   if TheSeries.DataSource=nil then
  1802.   begin
  1803.     if TheSeries.FunctionType<>nil then
  1804.     begin
  1805.       CBDataSourceStyle.ItemIndex:=dsStyle_Function;
  1806.       EnableDataSourceControls(False,True);
  1807.     end
  1808.     else
  1809.     begin
  1810.       if TheSeries.Count>0 then
  1811.          CBDataSourceStyle.ItemIndex:=dsStyle_Random
  1812.       else
  1813.          CBDataSourceStyle.ItemIndex:=dsStyle_NoData;
  1814.       EnableDataSourceControls(False,False);
  1815.     end;
  1816.   end
  1817.   else
  1818.   if TheSeries.DataSource is TChartSeries then
  1819.   begin
  1820.     CBDataSourceStyle.ItemIndex:=dsStyle_Function;
  1821.     EnableDataSourceControls(False,True);
  1822.   end
  1823.   else
  1824.   begin
  1825.     CBDataSourceStyle.ItemIndex:=dsStyle_Dataset;
  1826.     EnableDataSourceControls(True,False);
  1827.   end;
  1828. end;
  1829.  
  1830. procedure TChartEditForm.CBMarksVisibleClick(Sender: TObject);
  1831. begin
  1832.   TheSeries.Marks.Visible:=CBMarksVisible.Checked;
  1833. end;
  1834.  
  1835. procedure TChartEditForm.CBTransparentClick(Sender: TObject);
  1836. begin
  1837.   TheSeries.Marks.Transparent:=CBTransparent.Checked;
  1838. end;
  1839.  
  1840. procedure TChartEditForm.CBMarkClipClick(Sender: TObject);
  1841. begin
  1842.   TheSeries.Marks.Clip:=CBMarkClip.Checked;
  1843. end;
  1844.  
  1845. procedure TChartEditForm.SEArrowLengthChange(Sender: TObject);
  1846. begin
  1847.   if SEArrowLength.Text<>'' then
  1848.      TheSeries.Marks.ArrowLength:=SEArrowLength.Value;
  1849. end;
  1850.  
  1851. procedure TChartEditForm.SetTabTitle;
  1852. begin
  1853.   With SelectedTitle do
  1854.   begin
  1855.     Case Alignment of
  1856.       taLeftJustify:  RGTitAlign.ItemIndex:=0;
  1857.       taCenter:       RGTitAlign.ItemIndex:=1;
  1858.       taRightJustify: RGTitAlign.ItemIndex:=2;
  1859.     end;
  1860.     CBTitleVisible.Checked :=Visible;
  1861.     CBTitleAdjust.Checked  :=AdjustFrame;
  1862.     MTitle.Font.Assign(Font);
  1863.     CreatingForm:=True;
  1864.     MTitle.Lines:=Text;
  1865.     CreatingForm:=False;
  1866.   end;
  1867. end;
  1868.  
  1869. Procedure TChartEditForm.RefreshWallColorShape(AWall:TChartWall);
  1870. begin
  1871.   if AWall=TheChart.LeftWall then
  1872.      SHWallColor.Brush.Color:=AWall.Color
  1873.   else
  1874.   if AWall=TheChart.BottomWall then
  1875.      SHWallColor2.Brush.Color:=AWall.Color
  1876.   else
  1877.      SHWallColor3.Brush.Color:=AWall.Color
  1878. end;
  1879.  
  1880. Procedure TChartEditForm.RefreshWallDark(AWall:TChartWall);
  1881. var tmp:TCheckBox;
  1882. begin
  1883.   if AWall=TheChart.LeftWall then tmp:=CBWallDark else
  1884.   if AWall=TheChart.BottomWall then tmp:=CBWallDarkBot else
  1885.      tmp:=CBWallDarkBack;
  1886.   tmp.Checked:=AWall.Dark3D;
  1887.   tmp.Enabled:=AWall.Size>0;
  1888. end;
  1889.  
  1890. procedure TChartEditForm.SetTabWalls(AWall:TChartWall);
  1891. var tmp:TCheckBox;
  1892.     tmpSE:TSpinEdit;
  1893. begin
  1894.   CBView3dWalls.Checked:=TheChart.View3dWalls;
  1895.   if AWall=TheChart.LeftWall then tmpSE:=SEWallSize else
  1896.   if AWall=TheChart.BottomWall then tmpSE:=SEWallSize2 else
  1897.      tmpSE:=SEWallSize3;
  1898.   tmpSE.Value:=AWall.Size;
  1899.   RefreshWallDark(AWall);
  1900.   RefreshWallColorShape(AWall);
  1901.   if AWall=TheChart.LeftWall then tmp:=CBLeftWallTrans else
  1902.   if AWall=TheChart.BottomWall then tmp:=CBBotWallTrans else
  1903.      tmp:=CBBackWallTrans;
  1904.   CreatingForm:=True;
  1905.   tmp.Checked:=AWall.Brush.Style=bsClear;
  1906.   CreatingForm:=False;
  1907. end;
  1908.  
  1909. procedure TChartEditForm.EnableImageControls;
  1910. begin
  1911.   RGBitmap.Enabled:=(TheChart.BackImage.Graphic<>nil);
  1912.   CBImageInside.Enabled:=RGBitmap.Enabled;
  1913.   if TheChart.BackImage.Graphic<>nil then
  1914.      BBrowseImage.Caption:=TeeMsg_ClearImage
  1915.   else
  1916.      BBrowseImage.Caption:=TeeMsg_BrowseImage;
  1917. end;
  1918.  
  1919. Type
  1920.   TFakeWinControl = Class(TWinControl)
  1921.   public
  1922.     procedure FreeHandle;
  1923.   end;
  1924.  
  1925. procedure TFakeWinControl.FreeHandle;
  1926. begin
  1927.   DestroyHandle;
  1928. end;
  1929.  
  1930. procedure TChartEditForm.Notebook1Change(Sender: TObject; NewTab: Integer;
  1931.   var AllowChange: Boolean);
  1932.  
  1933.   Procedure SetTab3D;
  1934.   begin
  1935.     With TheChart do
  1936.     begin
  1937.       CBView3D.Checked       :=View3d;
  1938.       SE3D.Value             :=Chart3dPercent;
  1939.       With View3DOptions do
  1940.       begin
  1941.         CBOrthogonal.Checked   :=Orthogonal;
  1942.         SBZoom.Position        :=Zoom;
  1943.         SBRot.Position         :=Rotation;
  1944.         SBElev.Position        :=Elevation;
  1945.         SBHorizOf.Position     :=HorizOffset;
  1946.         SBVertOf.Position      :=VertOffset;
  1947.         CBZoomFonts.Checked    :=ZoomText;
  1948.         SBPerspec.Position     :=Perspective;
  1949.       end;
  1950.       Refresh3DControls;
  1951.     end;
  1952.   end;
  1953.  
  1954.   Procedure SetTabGeneral;
  1955.   begin
  1956.     With TheChart do
  1957.     begin
  1958.       RGPanning.ItemIndex    :=Ord(AllowPanning);
  1959.       CBClipPoints.Checked   :=ClipPoints;
  1960.       SETopMa.Value          :=MarginTop;
  1961.       SELeftMa.Value         :=MarginLeft;
  1962.       SEBotMa.Value          :=MarginBottom;
  1963.       SERightMa.Value        :=MarginRight;
  1964.       CBAllowZoom.Checked    :=AllowZoom;
  1965.       CBAnimatedZoom.Checked :=AnimatedZoom;
  1966.       SEAniZoomSteps.Value   :=AnimatedZoomSteps;
  1967.     end;
  1968.   end;
  1969.  
  1970.   procedure SetTabLegend;
  1971.   begin
  1972.     With TheChart do
  1973.     begin
  1974.       SETopLegPos.Value      :=Legend.TopPos;
  1975.       SELegColWi.Value       :=Legend.ColorWidth;
  1976.       SELegShadowSize.Value  :=TChartLegend(Legend).ShadowSize;
  1977.       CBResizeChart.Checked  :=Legend.ResizeChart;
  1978.       CBLegendStyle.ItemIndex:=Ord(Legend.LegendStyle);
  1979.       CBLegStyle.ItemIndex   :=Ord(Legend.TextStyle);
  1980.       CBShowLeg.Checked      :=Legend.Visible;
  1981.       Case Legend.Alignment of
  1982.         laTop   : RBLegendTop.Checked:=True;
  1983.         laBottom: RBLegendBottom.Checked:=True;
  1984.         laLeft  : RBLegendLeft.Checked:=True;
  1985.         laRight : RBLegendRight.Checked:=True;
  1986.       end;
  1987.       EnableLegendMarginControls;
  1988.     end;
  1989.   end;
  1990.  
  1991.   procedure SetTabPanel;
  1992.   begin
  1993.     With TheChart do
  1994.     begin
  1995.       RGBevelIn.ItemIndex    :=Ord(BevelInner);
  1996.       RGBevelOut.ItemIndex   :=Ord(BevelOuter);
  1997.       CBPanelBorder.Checked  :=BorderStyle=bsSingle;
  1998.       SEPanelWi.Value        :=BevelWidth;
  1999.       SEPanelBor.Value       :=BorderWidth;
  2000.       CBGradientVisible.Checked:=Gradient.Visible;
  2001.       CheckGradientVisible;
  2002.       RGBitmap.ItemIndex     :=Ord(BackImageMode);
  2003.       CBImageInside.Checked  :=BackImageInside;
  2004.       EnableImageControls;
  2005.     end;
  2006.   end;
  2007.  
  2008.   procedure SetTabPaging;
  2009.   begin
  2010.     With TheChart do
  2011.     begin
  2012.       SEPointsPerPage.Value  :=MaxPointsPerPage;
  2013.       CBScaleLast.Checked    :=ScaleLastPage;
  2014.       TheChartPageChange(Self);
  2015.     end;
  2016.   end;
  2017.  
  2018.   Procedure SetTabAxis;
  2019.   var tmp:Boolean;
  2020.   begin
  2021.     CBShowAxis.Checked   :=TheAxis.ParentChart.AxisVisible;
  2022.     CBAxisVisible.Checked:=TheAxis.Visible;
  2023.     PageControlAxis.PageIndex:=0;
  2024.     PageControlAxisChange(Self,PageControlAxis.PageIndex,tmp);
  2025.   end;
  2026.  
  2027. begin
  2028.   CreatingForm:=True;
  2029.   With Notebook1 do  { fix resource comsumption }
  2030.        TFakeWinControl(Pages.Objects[PageIndex]).FreeHandle;
  2031.   Case NewTab of
  2032.     1: SetTabGeneral;
  2033.     2: SetTabAxis;
  2034.     3: SetTabTitle;
  2035.     4: SetTabLegend;
  2036.     5: SetTabPanel;
  2037.     6: SetTabPaging;
  2038.     7: SetTabWalls(SelectedWall);
  2039.     8: SetTab3D;
  2040.   end;
  2041.   CreatingForm:=False;
  2042. end;
  2043.  
  2044. type TGetStrProc = procedure(const S: string) of object;
  2045.  
  2046. procedure TChartEditForm.ProcGetCursors(const S: string);
  2047. begin
  2048.   CBSeriesCursor.Items.Add(S);
  2049. end;
  2050.  
  2051. procedure TChartEditForm.SetTabSeriesGeneral;
  2052. var tmpSt:String;
  2053. begin
  2054.   With TheSeries do
  2055.   begin
  2056.     CBShowInLegend.Checked   :=ShowInLegend;
  2057.     EValueFormat.Text        :=DelphiToLocalFormat(ValueFormat);
  2058.     EPercentFormat.Text      :=DelphiToLocalFormat(PercentFormat);
  2059.     Case HorizAxis of
  2060.       aTopAxis   : RGHorizAxis.ItemIndex:=0;
  2061.       aBottomAxis: RGHorizAxis.ItemIndex:=1;
  2062.       aBothHorizAxis: RGHorizAxis.ItemIndex:=2;
  2063.     end;
  2064.     Case VertAxis of
  2065.       aLeftAxis  : RGVertAxis.ItemIndex:=0;
  2066.       aRightAxis : RGVertAxis.ItemIndex:=1;
  2067.       aBothVertAxis: RGVertAxis.ItemIndex:=2;
  2068.     end;
  2069.     CBXDateTime.Checked:=XValues.DateTime;
  2070.     CBYDateTime.Checked:=YValues.DateTime;
  2071.   end;
  2072.   With CBSeriesCursor do
  2073.   begin
  2074.     Items.BeginUpdate;
  2075.     Clear;
  2076.     GetCursorValues(ProcGetCursors);
  2077.     Items.Add(TeeMsg_TeeHand);
  2078.     Items.EndUpdate;
  2079.   end;
  2080.   if TeeCursorToIdent(TheSeries.Cursor,tmpSt) then
  2081.      CBSeriesCursor.ItemIndex:=CBSeriesCursor.Items.IndexOf(tmpSt)
  2082.   else
  2083.      CBSeriesCursor.ItemIndex:=-1;
  2084. end;
  2085.  
  2086. procedure TChartEditForm.BMarkFontClick(Sender: TObject);
  2087. begin
  2088.   With TheSeries.Marks do Font:=InternalEditFont(Self,Font);
  2089. end;
  2090.  
  2091. procedure TChartEditForm.BMarksFrameClick(Sender: TObject);
  2092. begin
  2093.   EditChartPen(Self,TheSeries.Marks.Frame);
  2094. end;
  2095.  
  2096. procedure TChartEditForm.BMarkLinColClick(Sender: TObject);
  2097. begin
  2098.   EditChartPen(Self,TheSeries.Marks.Arrow);
  2099. end;
  2100.  
  2101. procedure TChartEditForm.BAxisPenClick(Sender: TObject);
  2102. begin
  2103.   EditChartPen(Self,TheAxis.Axis);
  2104. end;
  2105.  
  2106. procedure TChartEditForm.CBSeriesCursorChange(Sender: TObject);
  2107. var tmpCursor:Longint;
  2108. begin
  2109.   if TeeIdentToCursor(CBSeriesCursor.Items[CBSeriesCursor.ItemIndex], tmpCursor) then
  2110.      TheSeries.Cursor:=tmpCursor;
  2111. end;
  2112.  
  2113. procedure TChartEditForm.CBView3dClick(Sender: TObject);
  2114. begin
  2115.   if not CreatingForm then
  2116.   Begin
  2117.     TheChart.View3d:=CBView3d.Checked;
  2118.     Refresh3DControls;
  2119.   end;
  2120. end;
  2121.  
  2122. procedure TChartEditForm.Refresh3DControls;
  2123. begin
  2124.   With TheChart do
  2125.   begin
  2126.     SBRot.Enabled:=View3D and (not View3DOptions.Orthogonal);
  2127.     SBElev.Enabled:=SBRot.Enabled;
  2128.     SBPerspec.Enabled:=SBRot.Enabled;
  2129.     EnableControls(View3D,[ SE3D,CBOrthogonal,SBZoom,CBZoomFonts,
  2130.                             SBHorizOf,SBVertOf]);
  2131.   end;
  2132. end;
  2133.  
  2134. procedure TChartEditForm.RGTitalignClick(Sender: TObject);
  2135. begin
  2136.   if not CreatingForm then
  2137.   With SelectedTitle do
  2138.   Case RGTitAlign.ItemIndex of
  2139.     0: Alignment:=taLeftJustify;
  2140.     1: Alignment:=taCenter;
  2141.     2: Alignment:=taRightJustify;
  2142.   end;
  2143. end;
  2144.  
  2145. procedure TChartEditForm.RGVertAxisClick(Sender: TObject);
  2146. begin
  2147.   Case RGVertAxis.ItemIndex of
  2148.     0: TheSeries.VertAxis:=aLeftAxis;
  2149.     1: TheSeries.VertAxis:=aRightAxis;
  2150.     2: TheSeries.VertAxis:=aBothVertAxis;
  2151.   end;
  2152. end;
  2153.  
  2154. procedure TChartEditForm.BAxisTickPenClick(Sender: TObject);
  2155. begin
  2156.   EditChartPen(Self,TheAxis.Ticks);
  2157. end;
  2158.  
  2159. procedure TChartEditForm.CBShowInLegendClick(Sender: TObject);
  2160. begin
  2161.   TheSeries.ShowInLegend:=CBShowInLegend.Checked;
  2162. end;
  2163.  
  2164. procedure TChartEditForm.SetCurrentDataSource;
  2165. begin
  2166.   if TheSource.SelectedDataSource=nil then
  2167.      CBListDataSets.ItemIndex:=-1
  2168.   else
  2169.      CBListDataSets.ItemIndex:=CBListDataSets.Items.IndexOfObject(TheSource.SelectedDataSource);
  2170. end;
  2171.  
  2172. procedure TChartEditForm.FillSourceDatasets;
  2173. begin
  2174.   CBListDataSets.Items.Clear;
  2175.   FillSources(CBListDataSets.Items,True);
  2176.   SetCurrentDataSource;
  2177.   ApplyChangesDataSet:=True;
  2178. end;
  2179.  
  2180. procedure TChartEditForm.FillSourceSeries;
  2181. begin
  2182.   FillTeeFunctions(CBFunctions.Items);
  2183.   LBAvailSeries.Items.Clear;
  2184.   FillSources(LBAvailSeries.Items,False);
  2185.   if TheSource.SelectedDataSource=nil then
  2186.      LBAvailSeries.ItemIndex:=-1
  2187.   else
  2188.      LBAvailSeries.ItemIndex:=LBAvailSeries.Items.IndexOfObject(TheSource.SelectedDataSource);
  2189.   SetSelectedSourceSeries;
  2190. end;
  2191.  
  2192. procedure TChartEditForm.EnableDataSourceControls(IsDatabase,IsFunction:Boolean);
  2193. begin
  2194.   if IsDatabase then
  2195.   begin
  2196.     SetTabSeriesDatabase;
  2197.     PageControl2.PageIndex:=0;
  2198.   end
  2199.   else
  2200.   if IsFunction then
  2201.   begin
  2202.     SetTabSeriesFunctions;
  2203.     PageControl2.PageIndex:=1;
  2204.   end;
  2205.   PageControl2.Visible:=IsDatabase or IsFunction;
  2206. end;
  2207.  
  2208. procedure TChartEditForm.SetSelectedSourceSeries;
  2209. begin
  2210. end;
  2211.  
  2212. procedure TChartEditForm.SetSelectedSourceDatabase;
  2213. begin
  2214.   CBLabelsField.Items.Clear;
  2215.   CBLabelsField.Enabled:= (CBListDataSets.ItemIndex<>-1) and
  2216.                           (CBDataSourceStyle.ItemIndex=dsStyle_Dataset);
  2217.   TheSource.ClearCombos(CBListDataSets.ItemIndex<>-1);
  2218.   if CBListDataSets.ItemIndex=-1 then TheSource.SelectedDataSource:=nil
  2219.   else
  2220.   begin
  2221.     TheSource.SelectedDataSource:=TComponent(CBListDataSets.Items.Objects[CBListDataSets.ItemIndex]);
  2222.     if Assigned(TheSource.SelectedDataSource) then FillFields;
  2223.   end;
  2224.   CBLabelsField.ItemIndex:=CBLabelsField.Items.IndexOf(TheSource.SelectedXLabelsSource);
  2225.   TheSource.SetSeriesDatabaseSource(TheSeries);
  2226. end;
  2227.  
  2228. procedure TChartEditForm.CBListDataSetsChange(Sender: TObject);
  2229. begin
  2230.   SetSelectedSourceDatabase;
  2231.   ApplyChangesDataset:=True;
  2232. end;
  2233.  
  2234. procedure TChartEditForm.DoApplyChangesDataset;
  2235.  
  2236.   Procedure CheckFieldIsBlank(Const AFieldName:String);
  2237.   begin
  2238.     if AFieldName<>'' then
  2239.        Raise ChartException.CreateFmt(TeeMsg_FieldNotFound,[AFieldName]);
  2240.   end;
  2241.  
  2242.   Procedure CheckValidFields;
  2243.   var t:Longint;
  2244.   begin
  2245.     for t:=0 to TheSeries.ValuesLists.Count-1 do
  2246.     With TheSource.Values[t].CBValues do
  2247.          if ItemIndex=-1 then CheckFieldIsBlank(Text);
  2248.     With CBLabelsField do if ItemIndex=-1 then CheckFieldIsBlank(Text);
  2249.   end;
  2250.  
  2251. var t,tmp:Longint;
  2252. begin
  2253.   if Assigned(TheSeries) then
  2254.   With TheSeries do
  2255.   begin
  2256.     if TheSource.SelectedDataSource=nil then
  2257.        CBDataSourceStyle.ItemIndex:=dsStyle_NoData
  2258.     else
  2259.     begin
  2260.       CheckValidFields; { raise exception if non valid user input }
  2261.       DataSource:=nil;
  2262.       for t:=0 to ValuesLists.Count-1 do
  2263.       With ValuesLists.ValueList[t],TheSource.Values[t] do
  2264.       begin
  2265.         if CBValues.ItemIndex=-1 then ValueSource:=''
  2266.                                  else ValueSource:=SelectedValueSource;
  2267.         DateTime:=CBDateTime.Checked;
  2268.       end;
  2269.       With CBLabelsField do
  2270.       begin
  2271.         tmp:=Items.IndexOf(Text);
  2272.         if tmp<>ItemIndex then
  2273.         begin
  2274.           ItemIndex:=tmp;
  2275.           TheSource.SelectedXLabelsSource:=Items[ItemIndex];
  2276.         end;
  2277.         if ItemIndex=-1 then XLabelsSource:=''
  2278.                         else XLabelsSource:=TheSource.SelectedXLabelsSource;
  2279.       end;
  2280.       DataSource:=TheSource.SelectedDataSource;
  2281.     end;
  2282.   end;
  2283.   ApplyChangesDataSet:=False;
  2284. end;
  2285.  
  2286. procedure TChartEditForm.CBDateTimeClick(Sender: TObject);
  2287. begin
  2288.   ApplyChangesDataSet:=True;
  2289. end;
  2290.  
  2291. procedure TChartEditForm.CBValuesChange(Sender: TObject);
  2292. var tmp:Boolean;
  2293. begin
  2294.   With TComboBox(Sender),TheSource.Values[Tag] do
  2295.   begin
  2296.     if ItemIndex=-1 then SelectedValueSource:=''
  2297.                     else SelectedValueSource:=Items[ItemIndex];
  2298.     tmp:=CBDateTime.Checked;
  2299.     IsDateTimeSource(TheSource.SelectedDataSource,SelectedValueSource,tmp);
  2300.     CBDateTime.Checked:=tmp;
  2301.   end;
  2302.   ApplyChangesDataSet:=True;
  2303. end;
  2304.  
  2305. procedure TChartEditForm.CBLabelsFieldChange(Sender: TObject);
  2306. begin
  2307.   if CBLabelsField.ItemIndex=-1 then
  2308.      TheSource.SelectedXLabelsSource:=''
  2309.   else
  2310.      TheSource.SelectedXLabelsSource:=CBLabelsField.Items[CBLabelsField.ItemIndex];
  2311.   ApplyChangesDataSet:=True;
  2312. end;
  2313.  
  2314. procedure TChartEditForm.CBTickOnLabelsClick(Sender: TObject);
  2315. begin
  2316.   if not CreatingForm then
  2317.      TheAxis.TickOnLabelsOnly:=CBTickOnLabels.Checked;
  2318. end;
  2319.  
  2320. procedure TChartEditForm.BExportClick(Sender: TObject);
  2321. begin
  2322.   ChartExport(Self,TheChart);
  2323. end;
  2324.  
  2325. Procedure TChartEditForm.FillFields;  { virtual }
  2326. begin
  2327.   if Assigned(OnChartFillFields) then OnChartFillFields(Self);
  2328. end;
  2329.  
  2330. Procedure TChartEditForm.FillSources(AItems:TStrings; AddCurrent:Boolean);
  2331.  
  2332.   Procedure FillSourcesForm(AOwner:TComponent; Const AFormName:String);
  2333.   var t:Longint;
  2334.       AComponent:TComponent;
  2335.       tmp:String;
  2336.   begin
  2337.     if Assigned(AOwner) then
  2338.     for t:=0 to AOwner.ComponentCount-1 do
  2339.     begin
  2340.       AComponent:=AOwner.Components[t];
  2341.       if AddCurrent or (TheSeries.DataSources.IndexOf(AComponent)=-1) then
  2342.       if IsValidComponentSource(AComponent) then
  2343.          if TheSeries.ParentChart.IsValidDataSource(TheSeries,AComponent) then
  2344.          begin
  2345.            if AComponent is TChartSeries then
  2346.            With TChartSeries(AComponent) do
  2347.            begin
  2348.              if Title<>'' then tmp:=Title
  2349.                           else tmp:=Name;
  2350.            end
  2351.            else tmp:=AComponent.Name;
  2352.            if AFormName='' then
  2353.               AItems.AddObject(tmp,AComponent)
  2354.            else
  2355.               AItems.AddObject(AFormName+'.'+tmp,AComponent);
  2356.          end;
  2357.     end;
  2358.   end;
  2359.  
  2360. var t:Longint;
  2361. begin
  2362.   FillSourcesForm(TheSeries.ParentChart.Owner,'');
  2363.   FillSourcesForm(TheSeries.ParentChart,'');
  2364. end;
  2365.  
  2366. Function TChartEditForm.IsValidComponentSource(AComponent:TComponent):Boolean;
  2367. begin
  2368.   result:= (CBDataSourceStyle.ItemIndex=dsStyle_Function) and
  2369.            (AComponent is TChartSeries);
  2370.   if (not result) and (CBDataSourceStyle.ItemIndex=dsStyle_DataSet) then
  2371.      if Assigned(OnChartIsValidComponentSource) then
  2372.         result:=OnChartIsValidComponentSource(AComponent);
  2373. end;
  2374.  
  2375. Function TChartEditForm.IsDataSet:Boolean;
  2376. begin
  2377.   result:=False;
  2378. end;
  2379.  
  2380. procedure TChartEditForm.RGMarkStyleClick(Sender: TObject);
  2381. begin
  2382.   TheSeries.Marks.Style:=TSeriesMarksStyle(RGMarkStyle.ItemIndex);
  2383. end;
  2384.  
  2385. procedure TChartEditForm.RGPanningClick(Sender: TObject);
  2386. begin
  2387.   if not CreatingForm then TheChart.AllowPanning:=TPanningMode(RGPanning.ItemIndex);
  2388. end;
  2389.  
  2390. procedure TChartEditForm.FormClose(Sender: TObject;
  2391.   var Action: TCloseAction);
  2392. begin
  2393.   TheSource.Free;
  2394.   DestroySeriesForms;
  2395. end;
  2396.  
  2397. procedure TChartEditForm.SHWallColorMouseUp(Sender: TObject;
  2398.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  2399. begin
  2400.   With SelectedWall do Color:=EditColor(Self,Color);
  2401.   RefreshWallColorShape(SelectedWall);
  2402. end;
  2403.  
  2404. procedure TChartEditForm.SEAniZoomStepsChange(Sender: TObject);
  2405. begin
  2406.   if not CreatingForm then TheChart.AnimatedZoomSteps:=SEAniZoomSteps.Value;
  2407. end;
  2408.  
  2409. procedure TChartEditForm.RBLegendTopClick(Sender: TObject);
  2410. begin
  2411.   if not CreatingForm then
  2412.   begin
  2413.     TheChart.Legend.Alignment:=laTop;
  2414.     EnableLegendMarginControls;
  2415.   end;
  2416. end;
  2417.  
  2418. procedure TChartEditForm.RBLegendLeftClick(Sender: TObject);
  2419. begin
  2420.   if not CreatingForm then
  2421.   begin
  2422.     TheChart.Legend.Alignment:=laLeft;
  2423.     EnableLegendMarginControls;
  2424.   end;
  2425. end;
  2426.  
  2427. procedure TChartEditForm.RBLegendRightClick(Sender: TObject);
  2428. begin
  2429.   if not CreatingForm then
  2430.   begin
  2431.     TheChart.Legend.Alignment:=laRight;
  2432.     EnableLegendMarginControls;
  2433.   end;
  2434. end;
  2435.  
  2436. procedure TChartEditForm.RBLegendBottomClick(Sender: TObject);
  2437. begin
  2438.   if not CreatingForm then
  2439.   begin
  2440.     TheChart.Legend.Alignment:=laBottom;
  2441.     EnableLegendMarginControls;
  2442.   end;
  2443. end;
  2444.  
  2445. procedure TChartEditForm.CheckApplyChanges;
  2446. begin
  2447.   if ApplyChangesDataSet then DoApplyChangesDataSet
  2448.   else
  2449.   if ApplyChangesFunction then DoApplyChangesFunction;
  2450. end;
  2451.  
  2452. procedure TChartEditForm.BCloseClick(Sender: TObject);
  2453. begin
  2454.   CheckApplyChanges;
  2455.   ModalResult:=mrCancel;
  2456. end;
  2457.  
  2458. Function YesNoCancel(Const Message:String):Integer;
  2459. Begin
  2460.   Screen.Cursor:=crDefault;
  2461.   result:=MessageDlg(Message,mtConfirmation,mbYesNoCancel,0);
  2462. End;
  2463.  
  2464. procedure TChartEditForm.PageControlSeriesChanging(Sender: TObject;
  2465.   var AllowChange: Boolean);
  2466. begin
  2467.   AllowChange:=False;
  2468.   if (PageControlSeries.PageIndex=3) then
  2469.   begin
  2470.     if ApplyChangesDataset or ApplyChangesFunction then
  2471.        Case YesNoCancel(TeeMsg_SureToApply) of
  2472.          mrYes   : begin
  2473.                      try
  2474.                        if ApplyChangesDataset then DoApplyChangesDataset
  2475.                                               else DoApplyChangesFunction;
  2476.                        AllowChange:=True;
  2477.                      except
  2478.                        on E:Exception do Application.ShowException(E);
  2479.                      end;
  2480.                    end;
  2481.          mrNo    : begin
  2482.                      ApplyChangesDataSet:=False;
  2483.                      ApplyChangesFunction:=False;
  2484.                      AllowChange:=True;
  2485.                    end;
  2486.        end
  2487.     else
  2488.     if {(Sender=TabSeries) and }(TheSeries=nil) then AllowChange:=False
  2489.                                                 else AllowChange:=True;
  2490.   end
  2491.   else AllowChange:=True;
  2492. end;
  2493.  
  2494. procedure TChartEditForm.MainPageChanging(Sender: TObject;
  2495.   var AllowChange: Boolean);
  2496. begin
  2497.   PageControlSeriesChanging(Sender,AllowChange);
  2498. end;
  2499.  
  2500. procedure TChartEditForm.FormCloseQuery(Sender: TObject;
  2501.   var CanClose: Boolean);
  2502. begin
  2503.   PageControlSeriesChanging(Sender,CanClose);
  2504. end;
  2505.  
  2506. procedure TChartEditForm.EnableListButtons;
  2507. begin
  2508.   EnableControls(LBAvailSeries.Items.Count>0,[BRightOne,BRightAll]);
  2509.   EnableControls(LBSelectedSeries.Items.Count>0,[BLeftOne,BLeftAll]);
  2510. end;
  2511.  
  2512. procedure TChartEditForm.BRightOneClick(Sender: TObject);
  2513. begin
  2514.   MoveList(LBAvailSeries,LBSelectedSeries);
  2515.   EnableListButtons;
  2516.   ApplyChangesFunction:=True;
  2517. end;
  2518.  
  2519. procedure TChartEditForm.BLeftOneClick(Sender: TObject);
  2520. begin
  2521.   MoveList(LBSelectedSeries,LBAvailSeries);
  2522.   EnableListButtons;
  2523.   ApplyChangesFunction:=True;
  2524. end;
  2525.  
  2526. procedure TChartEditForm.BRightAllClick(Sender: TObject);
  2527. begin
  2528.   MoveListAll(LBAvailSeries,LBSelectedSeries);
  2529.   EnableListButtons;
  2530.   ApplyChangesFunction:=True;
  2531. end;
  2532.  
  2533. procedure TChartEditForm.BLeftAllClick(Sender: TObject);
  2534. begin
  2535.   MoveListAll(LBSelectedSeries,LBAvailSeries);
  2536.   EnableListButtons;
  2537.   ApplyChangesFunction:=True;
  2538. end;
  2539.  
  2540. procedure TChartEditForm.LBAvailSeriesDblClick(Sender: TObject);
  2541. begin
  2542.   BRightOneClick(Self);
  2543. end;
  2544.  
  2545. procedure TChartEditForm.LBSelectedSeriesDblClick(Sender: TObject);
  2546. begin
  2547.   BLeftOneClick(Self);
  2548. end;
  2549.  
  2550. procedure TChartEditForm.CBFunctionsChange(Sender: TObject);
  2551. begin
  2552.   ApplyChangesFunction:=True;
  2553. end;
  2554.  
  2555. procedure TChartEditForm.DoApplyChangesFunction;
  2556. var t:Longint;
  2557.     tmp:TChartSeries;
  2558.     tmpClass:TTeeFunctionClass;
  2559. begin
  2560.   { Set datasources... }
  2561.   if LBSelectedSeries.Items.Count=0 then TheSeries.DataSource:=nil
  2562.   else
  2563.   begin
  2564.     for t:=0 to LBSelectedSeries.Items.Count-1 do
  2565.     begin
  2566.       tmp:=TChartSeries(LBSelectedSeries.Items.Objects[t]);
  2567.       TheSeries.CheckOtherSeries(tmp);
  2568.     end;
  2569.     With TheSeries.DataSources do
  2570.     begin
  2571.       for t:=0 to Count-1 do
  2572.           TChartSeries(TheSeries.DataSources[t]).RemoveLinkedSeries(TheSeries);
  2573.       Clear;
  2574.       for t:=0 to LBSelectedSeries.Items.Count-1 do
  2575.       begin
  2576.         tmp:=TChartSeries(LBSelectedSeries.Items.Objects[t]);
  2577.         Add(tmp);
  2578.         TChartSeries(tmp).AddLinkedSeries(TheSeries);
  2579.       end;
  2580.     end;
  2581.   end;
  2582.   { Set function... }
  2583.   if CBFunctions.ItemIndex>0 then
  2584.   begin
  2585.     tmpClass:=TTeeFunctionClass(CBFunctions.Items.Objects[CBFunctions.ItemIndex]);
  2586.     if (TheSeries.FunctionType=nil) or
  2587.        (TheSeries.FunctionType.ClassType<>tmpClass) then
  2588.           CreateNewTeeFunction(TheSeries,tmpClass)
  2589.     else
  2590.           TheSeries.CheckDataSource;
  2591.   end
  2592.   else TheSeries.SetFunction(nil);
  2593.   ApplyChangesFunction:=False;
  2594. end;
  2595.  
  2596. Function TChartEditForm.GetSelectedSource:TComponent;
  2597. begin
  2598.   result:=TheSource.SelectedDataSource;
  2599. end;
  2600.  
  2601. Function TChartEditForm.GetSourceCombo(Index:Integer):TComboBox;
  2602. begin
  2603.   result:=TheSource.Values[Index].CBValues;
  2604. end;
  2605.  
  2606. procedure TChartEditForm.Button1Click(Sender: TObject);
  2607. begin
  2608.   EditChartPen(Self,TChartLegend(TheChart.Legend).DividingLines);
  2609. end;
  2610.  
  2611. procedure TChartEditForm.CBDataSourceStyleChange(Sender: TObject);
  2612. begin
  2613.   PageControl2.Visible:= (CBDataSourceStyle.ItemIndex<>dsStyle_NoData) and
  2614.                          (CBDataSourceStyle.ItemIndex<>dsStyle_Random);
  2615.   Case CBDataSourceStyle.ItemIndex of
  2616.     dsStyle_NoData:
  2617.        begin
  2618.          TheSource.ClearValueSources;
  2619.          EnableDataSourceControls(False,False);
  2620.          TheSeries.DataSource:=nil;
  2621.          TheSeries.Clear;
  2622.        end;
  2623.     dsStyle_Random:
  2624.        begin
  2625.          TheSource.ClearValueSources;
  2626.          EnableDataSourceControls(False,False);
  2627.          TheSeries.DataSource:=nil;
  2628.          TheSeries.FillSampleValues(TheSeries.NumSampleValues);
  2629.        end;
  2630.    dsStyle_Function: EnableDataSourceControls(False,True);
  2631.     dsStyle_Dataset: EnableDataSourceControls(True,False);
  2632.   end;
  2633. end;
  2634.  
  2635. procedure TChartEditForm.CBTitlesChange(Sender: TObject);
  2636. begin
  2637.   SetTabTitle;
  2638. end;
  2639.  
  2640. procedure TChartEditForm.CBSeriesChange(Sender: TObject);
  2641.  
  2642.     Procedure CreateTheSeriesForms;
  2643.     var tmpClass:TFormClass;
  2644.     begin
  2645.       tmpClass:=TFormClass(GetClass(TheSeries.GetEditorClass));
  2646.       if Assigned(tmpClass) then
  2647.       begin
  2648.         Inc(NumSeriesForms);
  2649.         TheSeriesForms[NumSeriesForms]:=tmpClass.Create(Self);
  2650.         AddSeriesForm(TheSeriesForms[NumSeriesForms],0,Longint(TheSeries));
  2651.       end
  2652.       else DestroySeriesForms;
  2653.     end;
  2654.  
  2655.     Procedure HideSeriesPage;
  2656.     begin
  2657.       ImageSeries.Visible:=False;
  2658.       LabelSeriesClass.Caption:='';
  2659.       PageControlSeries.Visible:=False;
  2660.     end;
  2661.  
  2662. var tmpBitmap : TBitmap;
  2663.     OldTab    : Integer;
  2664.     tmp       : Boolean;
  2665. begin
  2666.   CheckApplyChanges;
  2667.   With CBSeries do
  2668.   if ItemIndex<>-1 then
  2669.   begin
  2670.     OldTab:=PageControlSeries.PageIndex;
  2671.     TheSeries:=TChartSeries(CBSeries.Items.Objects[ItemIndex]);
  2672.     if Assigned(TheSeries) then
  2673.     begin
  2674.       tmpBitmap:=TBitmap.Create;
  2675.       try
  2676.         TheSeries.GetBitmapEditor(tmpBitmap);
  2677.         ImageSeries.Picture.Assign(tmpBitmap);
  2678.       finally
  2679.         tmpBitmap.Free;
  2680.       end;
  2681.       LabelSeriesClass.Caption:=GetGallerySeriesName(TheSeries)+': '+TheSeries.Name; { <-- don't translate }
  2682.       ImageSeries.Visible:=True;
  2683.       if OldTab=-1 then PageControlSeries.PageIndex:=0
  2684.                    else PageControlSeries.PageIndex:=OldTab;
  2685.       PageControlSeriesChange(Self,PageControlSeries.PageIndex,tmp);
  2686.       PageControlSeries.Visible:=False;
  2687.       RGHorizAxis.Visible:=TheSeries.UseAxis;
  2688.       RGVertAxis.Visible:=TheSeries.UseAxis;
  2689.       CBXDateTime.Visible:=TheSeries.UseAxis;
  2690.       CBYDateTime.Visible:=TheSeries.UseAxis;
  2691.       DestroySeriesForms;
  2692.       CreateTheSeriesForms;
  2693.       SetTabSeriesDataSource;
  2694.       PageControlSeries.Visible:=True;
  2695.     end
  2696.     else HideSeriesPage;
  2697.   end
  2698.   else HideSeriesPage;
  2699. end;
  2700.  
  2701. Function TChartEditForm.SelectedSeriesIndex:Integer;
  2702. begin
  2703.   result:=LBSeries.ItemIndex;
  2704. end;
  2705.  
  2706. Procedure TChartEditForm.RefreshButtons;
  2707. var tmp:Boolean;
  2708. begin
  2709.   tmp:=TheChart.SeriesCount>0;
  2710.   BAddSeries.Enabled:=(ceAdd in EditorOptions);
  2711.   BDeleteSeries.Enabled:=tmp and (ceDelete in EditorOptions);
  2712.   BRenameSeries.Enabled:=tmp and (LBSeries.SelCount<2);
  2713.   BChangeTypeSeries.Enabled:=tmp and (ceChange in EditorOptions);
  2714.   BCloneSeries.Enabled:=tmp and (LBSeries.SelCount<2) and (ceClone in EditorOptions);
  2715.   if tmp and (LBSeries.SelCount<=1) then
  2716.   begin
  2717.     BMoveDown.Enabled:=SelectedSeriesIndex<LBSeries.Items.Count-1;
  2718.     BMoveUp.Enabled:=SelectedSeriesIndex>0;
  2719.   end
  2720.   else
  2721.   begin
  2722.     BMoveDown.Enabled:=False;
  2723.     BMoveUp.Enabled:=False;
  2724.   end;
  2725. end;
  2726.  
  2727. procedure TChartEditForm.SwapSeries(tmp1,tmp2:Longint);
  2728. begin
  2729.   with LBSeries do
  2730.   begin
  2731.     Items.Exchange(tmp1,tmp2);
  2732.     CBSeries.Items.Exchange(tmp1,tmp2);
  2733.     TheChart.ExchangeSeries(tmp1,tmp2);
  2734.     Self.ActiveControl:=LBSeries;
  2735.     LBSeries.Selected[tmp2]:=True;
  2736.     LBSeries.Repaint;
  2737.     RefreshButtons;
  2738.   end;
  2739. end;
  2740.  
  2741. procedure TChartEditForm.BMoveUPClick(Sender: TObject);
  2742. begin
  2743.   With LBSeries do
  2744.   if ItemIndex>0 then SwapSeries(ItemIndex,ItemIndex-1);
  2745. end;
  2746.  
  2747. procedure TChartEditForm.BMoveDownClick(Sender: TObject);
  2748. begin
  2749.   With LBSeries do
  2750.   if (ItemIndex<>-1) and (SelectedSeriesIndex<Items.Count-1) then
  2751.      SwapSeries(ItemIndex,ItemIndex+1);
  2752. end;
  2753.  
  2754. Function TChartEditForm.SelectedSeries:TChartSeries;
  2755. begin
  2756.   if (LBSeries.ItemIndex<>-1) and
  2757.      (LBSeries.ItemIndex<TheChart.SeriesCount) then
  2758.      result:=TChartSeries(LBSeries.Items.Objects[LBSeries.ItemIndex])
  2759.   else
  2760.      result:=nil;
  2761. end;
  2762.  
  2763. procedure TChartEditForm.FillSeries(OldSeries:TChartSeries);
  2764. var t,tmpSelectedIndex:Longint;
  2765.     tmpSeries:TChartSeries;
  2766.     tmpSt:String;
  2767. Begin
  2768.   With TheChart do
  2769.   Begin
  2770.     LBSeries.Items.Clear;
  2771.     CBSeries.Items.Clear;
  2772.     tmpSelectedIndex:=-1;
  2773.     for t:=0 to SeriesCount-1 do
  2774.     begin
  2775.       tmpSeries:=Series[t];
  2776.       if tmpSeries.Title<>'' then tmpSt:=tmpSeries.Title
  2777.                              else tmpSt:=tmpSeries.Name;
  2778.       LBSeries.Items.AddObject(tmpSt,tmpSeries);
  2779.       CBSeries.Items.AddObject(tmpSt,tmpSeries);
  2780.       if Assigned(OldSeries) and (tmpSeries=OldSeries) then
  2781.          tmpSelectedIndex:=t;
  2782.     end;
  2783.     if tmpSelectedIndex=-1 then
  2784.        if SeriesCount>0 then tmpSelectedIndex:=0;
  2785.     if tmpSelectedIndex<>-1 then
  2786.     begin
  2787.       LBSeries.Selected[tmpSelectedIndex]:=True;
  2788.     end
  2789.     else PageControlSeries.Visible:=False;
  2790.     RefreshButtons;
  2791.   end;
  2792. end;
  2793.  
  2794. procedure TChartEditForm.BAddSeriesClick(Sender: TObject);
  2795. var tmpSeries:TChartSeries;
  2796.     tmp:Boolean;
  2797. begin
  2798.   tmpSeries:=CreateNewSeriesGallery(TheChart.Owner,SelectedSeries,TheChart,True,True);
  2799.   if Assigned(tmpSeries) then
  2800.   begin
  2801.     FillSeries(tmpSeries);
  2802.     if tmpSeries.FunctionType<>nil then
  2803.     begin
  2804.       TheSeries:=tmpSeries;
  2805.       SetTabSeries;
  2806.       MainPage.PageIndex:=1;
  2807.       PageControlSeries.PageIndex:=3;
  2808.       PageControlSeriesChange(Self,PageControlSeries.PageIndex,tmp);
  2809.     end;
  2810.   end;
  2811. end;
  2812.  
  2813. procedure TChartEditForm.BDeleteSeriesClick(Sender: TObject);
  2814. var NewFocusSeries:TChartSeries;
  2815.     t,i:Longint;
  2816.     tmpSt:String;
  2817. begin
  2818.   if LBSeries.SelCount>0 then
  2819.   begin
  2820.     if LBSeries.SelCount=1 then tmpSt:=SelectedSeries.Name
  2821.                            else tmpSt:=TeeMsg_SelectedSeries;
  2822.     if MessageDlg( Format(TeeMsg_SureToDeleteSeries,[tmpSt]),
  2823.                    mtConfirmation,[mbYes,mbNo],0)=mrYes then
  2824.     begin
  2825.       NewFocusSeries:=nil;
  2826.       t:=0;
  2827.       for i:=0 to LBSeries.Items.Count-1 do
  2828.       begin
  2829.         if LBSeries.Selected[i] then
  2830.         begin
  2831.          TheChart[t].Free;
  2832.          if t>(TheChart.SeriesCount-1) then t:=TheChart.SeriesCount-1;
  2833.          if (t>=0) and (t<TheChart.SeriesCount) then
  2834.             NewFocusSeries:=TheChart[t]
  2835.          else
  2836.             NewFocusSeries:=nil;
  2837.         end
  2838.         else inc(t);
  2839.       end;
  2840.       FillSeries(NewFocusSeries);
  2841.     end;
  2842.   end;
  2843. end;
  2844.  
  2845. procedure TChartEditForm.BRenameSeriesClick(Sender: TObject);
  2846. var tmpSt:String;
  2847.     tmpSeries:TChartSeries;
  2848.     tmp:Longint;
  2849. begin
  2850.   tmp:=LBSeries.ItemIndex;
  2851.   if tmp<>-1 then
  2852.   begin
  2853.     tmpSeries:=SelectedSeries;
  2854.     tmpSt:=tmpSeries.Title;
  2855.     if tmpSt='' then tmpSt:=tmpSeries.Name;
  2856.     if InputQuery( TeeMsg_ChangeSeriesTitle,
  2857.                    TeeMsg_NewSeriesTitle,tmpSt) then
  2858.     if tmpSt<>'' then
  2859.     begin
  2860.       if tmpSt<>tmpSeries.Name then tmpSeries.Title:=tmpSt;
  2861.       LBSeries.Items[tmp]:=tmpSt;
  2862.       CBSeries.Items[tmp]:=tmpSt;
  2863.     end;
  2864.     Self.ActiveControl:=LBSeries;
  2865.     LBSeries.Selected[tmp]:=True;
  2866.   end;
  2867. end;
  2868.  
  2869. procedure TChartEditForm.BCloneSeriesClick(Sender: TObject);
  2870. begin
  2871.   if LBSeries.ItemIndex<>-1 then
  2872.      FillSeries(CloneChartSeries(SelectedSeries));
  2873. end;
  2874.  
  2875. procedure TChartEditForm.BChangeTypeSeriesClick(Sender: TObject);
  2876. var tmpSeries:TChartSeries;
  2877.     NewClass:TChartSeriesClass;
  2878.     t:Longint;
  2879.     FirstTime:Boolean;
  2880. begin
  2881.   if LBSeries.SelCount>0 then
  2882.   begin
  2883.     FirstTime:=True;
  2884.     NewClass:=nil;
  2885.     for t:=0 to LBSeries.Items.Count-1 do
  2886.     if LBSeries.Selected[t] then
  2887.     begin
  2888.       tmpSeries:=TheChart[t];
  2889.       if FirstTime then
  2890.       begin
  2891.         ChangeSeriesTypeGallery(tmpSeries.Owner,tmpSeries);
  2892.         NewClass:=TChartSeriesClass(tmpSeries.ClassType);
  2893.         FirstTime:=False;
  2894.       end
  2895.       else ChangeSeriesType(tmpSeries,NewClass);
  2896.     end;
  2897.     FillSeries(tmpSeries);
  2898.   end;
  2899. end;
  2900.  
  2901. Function TChartEditForm.SeriesAtMousePos(Var p:TPoint):Longint;
  2902. begin
  2903.   GetCursorPos(p);
  2904.   p:=LBSeries.ScreenToClient(p);
  2905.   result:=LBSeries.ItemAtPos(p,True);
  2906. end;
  2907.  
  2908. Function TChartEditForm.PointInSection(Const P:TPoint; ASection:Longint):Boolean;
  2909. Var tmpPos:Longint;
  2910. begin
  2911.   Case ASection of
  2912.     0: tmpPos:=0;
  2913.     1: tmpPos:=28;
  2914.     2: tmpPos:=44;
  2915.     3: tmpPos:=58;
  2916.   end;
  2917.   result:=(p.x>tmpPos) and (p.x<tmpPos+HeaderControl1.SectionWidth[ASection]);
  2918. end;
  2919.  
  2920. procedure TChartEditForm.LBSeriesDblClick(Sender: TObject);
  2921. var p:TPoint;
  2922.     tmp:Longint;
  2923. begin
  2924.   ComingFromDoubleClick:=True;
  2925.   tmp:=SeriesAtMousePos(p);
  2926.   if (tmp<>-1) and LBSeries.Selected[tmp] then
  2927.   begin
  2928.     if PointInSection(p,0) then BChangeTypeSeriesClick(Self)
  2929.     else
  2930.     if PointInSection(p,2) then
  2931.     begin
  2932.       With TheChart[tmp] do
  2933.       if not ColorEachPoint then
  2934.       begin
  2935.         SeriesColor:=EditColor(Self,SeriesColor);
  2936.         LBSeries.Repaint;
  2937.       end;
  2938.     end
  2939.     else
  2940.     if PointInSection(p,3) then BEditSeriesClick;
  2941.   end;
  2942. end;
  2943.  
  2944. procedure TChartEditForm.LBSeriesDragDrop(Sender, Source: TObject; X,
  2945.   Y: Integer);
  2946. var tmp1,tmp2:Longint;
  2947. begin
  2948.   With TListBox(Sender) do
  2949.   if ItemIndex<>-1 then
  2950.   begin
  2951.     tmp1:=ItemIndex;
  2952.     tmp2:=ItemAtPos(Point(X,Y),True);
  2953.     if (tmp2<>-1) and (tmp1<>tmp2) then SwapSeries(tmp1,tmp2);
  2954.   end;
  2955. end;
  2956.  
  2957. procedure TChartEditForm.LBSeriesDrawItem(Control: TWinControl;
  2958.   Index: Integer; Rect: TRect; State: TOwnerDrawState);
  2959. var tmp:Integer;
  2960.     tmpBitmap:TBitmap;
  2961.     tmpSeries:TChartSeries;
  2962.     tmpR,CBRect:TRect;
  2963.     tmpCanvas:TCanvas;
  2964.     OldCanvas:TCanvas;
  2965. begin
  2966.   tmpCanvas:=LBSeries.Canvas;
  2967.   With tmpCanvas do
  2968.   begin
  2969.     tmpSeries:=TheChart[Index];
  2970.  
  2971.     if odSelected in State then
  2972.        Brush.Color:=clHighLight
  2973.     else
  2974.        Brush.Color:=clWindow;
  2975.     FillRect(Rect);
  2976.  
  2977.     Brush.Color:=TheChart.Legend.Color;
  2978.     Brush.Style:=bsSolid;
  2979.     tmpR.Top    :=Rect.Top;
  2980.     tmpR.Bottom :=Rect.Bottom;
  2981.     tmpR.Left   :=Rect.Left;
  2982.     tmpR.Right  :=46{HeaderControl1.Sections[2].Left}+HeaderControl1.SectionWidth[2]-4;
  2983.     FillRect(tmpR);
  2984.  
  2985.     tmp:=2{HeaderControl1.Sections[0].Left};
  2986.     tmpBitmap:=TBitmap.Create;
  2987.     try
  2988.       tmpSeries.GetBitmapEditor(tmpBitmap);
  2989.       Draw(tmp,Rect.Top+2,tmpBitmap);
  2990.     finally
  2991.       tmpBitmap.Free;
  2992.     end;
  2993.  
  2994.     if not tmpSeries.ColorEachPoint then
  2995.     begin
  2996.       tmp:=44{HeaderControl1.Sections[2].Left}-2;
  2997.       tmpR:=Classes.Rect(tmp,Rect.Top,tmp+HeaderControl1.SectionWidth[2],Rect.Bottom);
  2998.       InflateRect(tmpR,-4,-4);
  2999.  
  3000.       Brush.Style:=bsSolid;
  3001.       Brush.Color:=TheChart.Legend.Color;
  3002.       With TheChart do
  3003.       begin
  3004.         OldCanvas:=Canvas.ReferenceCanvas;
  3005.         Canvas.ReferenceCanvas:=tmpCanvas;
  3006.         try
  3007.           Series[Index].DrawLegend(-1,tmpR);
  3008.         finally
  3009.           Canvas.ReferenceCanvas:=OldCanvas;
  3010.         end;
  3011.       end;
  3012.     end;
  3013.  
  3014.     tmp:=28{HeaderControl1.Sections[1].Left};
  3015.     CBRect:=Classes.Rect(tmp,Rect.Top+6,tmp+12,Rect.Top+18);
  3016.     Brush.Style:=bsClear;
  3017.     SetBkMode(Handle,Transparent);
  3018.     Pen.Color:=clBlack;
  3019.     Pen.Style:=psSolid;
  3020.     With CBRect do Rectangle(Left,Top,Right,Bottom);
  3021.     if tmpSeries.Active then
  3022.     With CBRect do
  3023.     begin
  3024.       MoveTo(Left,Top);
  3025.       LineTo(Right,Bottom);
  3026.       MoveTo(Left,Bottom-1);
  3027.       LineTo(Right,Top-1);
  3028.     end;
  3029.  
  3030.     tmp:=80;
  3031.     if odSelected in State then
  3032.        Font.Color:=clHighlightText
  3033.     else
  3034.        Font.Color:=clBlack;
  3035.     Brush.Style:=bsClear;
  3036.     TextOut(tmp,Rect.Top+6,LBSeries.Items[Index]);
  3037.   end;
  3038. end;
  3039.  
  3040. procedure TChartEditForm.LBSeriesDragOver(Sender, Source: TObject; X,
  3041.   Y: Integer; State: TDragState; var Accept: Boolean);
  3042. begin
  3043.   Accept:=Sender=Source;
  3044. end;
  3045.  
  3046. procedure TChartEditForm.LBSeriesKeyUp(Sender: TObject; var Key: Word;
  3047.   Shift: TShiftState);
  3048. begin
  3049.   if Key=VK_DELETE then BDeleteSeriesClick(Self);
  3050. end;
  3051.  
  3052. procedure TChartEditForm.SetTabSeries;
  3053. begin
  3054.   if TheChart.SeriesCount=0 then
  3055.   begin
  3056.     TheSeries:=nil;
  3057.     PageControlSeries.Visible:=False;
  3058.   end
  3059.   else
  3060.   begin
  3061.     TheSeries:=SelectedSeries;
  3062.     CBSeries.ItemIndex:=CBSeries.Items.IndexOfObject(TheSeries);
  3063.     CBSeriesChange(Self);
  3064.     if Assigned(InternalOnCreateEditSeries) then InternalOnCreateEditSeries(Self,TheChart);
  3065.   end;
  3066. end;
  3067.  
  3068. Procedure TChartEditForm.IsDateTimeSource( AComponent:TComponent;
  3069.                                            Const ValueSource:String;
  3070.                                            Var IsDateTime:Boolean);
  3071. begin
  3072.   if Assigned(OnChartIsDateTimeSource) then
  3073.      OnChartIsDateTimeSource(AComponent,ValueSource,IsDateTime);
  3074. end;
  3075.  
  3076. procedure TChartEditForm.LBSeriesMouseDown(Sender: TObject;
  3077.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  3078. var tmp:Longint;
  3079.     p:TPoint;
  3080. begin
  3081.   if (LBSeries.ItemIndex<>-1) then
  3082.   begin
  3083.     tmp:=SeriesAtMousePos(p);
  3084.     if (tmp<>-1) and (PointInSection(p,1)) then
  3085.     begin
  3086.       with TheChart[tmp] do Active:=not Active;
  3087.       LBSeries.Repaint;
  3088.     end
  3089.     else
  3090.     if PointInSection(p,3) and (not ComingFromDoubleClick) and
  3091.        (not (ssShift in Shift)) and
  3092.        (not (ssCtrl in Shift)) then
  3093.             LBSeries.BeginDrag(False);
  3094.     ComingFromDoubleClick:=False;
  3095.     CBSeries.ItemIndex:=LBSeries.ItemIndex;
  3096.   end;
  3097. end;
  3098.  
  3099. procedure TChartEditForm.BBrowseImageClick(Sender: TObject);
  3100. begin
  3101.   if TheChart.BackImage.Graphic<>nil then
  3102.      TheChart.BackImage.Assign(nil)
  3103.   else
  3104.   With TOpenDialog.Create(Self) do
  3105.   try
  3106.     DefaultExt:=TeeGetImageExtension(0);
  3107.     Filter:=GraphicFilter(TBitmap);
  3108.     Options:=Options+[ofHideReadOnly];
  3109.     if Execute then
  3110.        TheChart.BackImage.LoadFromFile(FileName);
  3111.     EnableImageControls;
  3112.   finally
  3113.     Free;
  3114.   end;
  3115.   EnableImageControls;
  3116. end;
  3117.  
  3118. procedure TChartEditForm.CBImageInsideClick(Sender: TObject);
  3119. begin
  3120.   TheChart.BackImageInside:=CBImageInside.Checked;
  3121. end;
  3122.  
  3123. procedure TChartEditForm.CBXDateTimeClick(Sender: TObject);
  3124. begin
  3125.   TheSeries.XValues.DateTime:=CBXDateTime.Checked;
  3126. end;
  3127.  
  3128. procedure TChartEditForm.CBYDateTimeClick(Sender: TObject);
  3129. begin
  3130.   TheSeries.YValues.DateTime:=CBYDateTime.Checked;
  3131. end;
  3132.  
  3133. procedure TChartEditForm.LBSeriesClick(Sender: TObject);
  3134. begin
  3135.   RefreshButtons;
  3136. end;
  3137.  
  3138. procedure TChartEditForm.SE3dChange(Sender: TObject);
  3139. begin
  3140.   if not CreatingForm then TheChart.Chart3DPercent:=SE3d.Value;
  3141. end;
  3142.  
  3143. Function TChartEditForm.ChangeMargin(AEdit:TSpinEdit; APos,OtherSide:Integer):Integer;
  3144. begin
  3145.   result:=APos;
  3146.   if AEdit.Value+OtherSide<100 then result:=AEdit.Value
  3147.                                else AEdit.Value:=APos;
  3148. end;
  3149.  
  3150. procedure TChartEditForm.DestroySeriesForms;
  3151. var t       : Integer;
  3152.     tmp     : Integer;
  3153.     tmpPage : TTabPage;
  3154. begin
  3155.   for t:=1 to NumSeriesForms do
  3156.   if Assigned(TheSeriesForms[t]) then
  3157.   begin
  3158.     tmpPage:=(TheSeriesForms[t].Parent as TTabPage);
  3159.     TheSeriesForms[t].Free;
  3160.     TheSeriesForms[t]:=nil;
  3161.     tmp:=PageControlSeries.GetIndexForPage(tmpPage.Caption);
  3162.     if tmp>0 then
  3163.        if not (csDestroying in PageControlSeries.ComponentState) then
  3164.           PageControlSeries.Pages.Delete(tmp);
  3165.   end;
  3166.   NumSeriesForms:=0;
  3167. end;
  3168.  
  3169. Procedure TChartEditForm.AddSeriesForm(AForm:TForm; ATabIndex:Integer; ATag:Longint);
  3170. begin
  3171.   With AForm do
  3172.   begin
  3173.     Position:=poDesigned;
  3174.     BorderStyle:=bsNone;
  3175.     BorderIcons:=[];
  3176.     Tag:=ATag;
  3177.     Parent:=TTabPage(PageControlSeries.Pages.Objects[ATabIndex]);
  3178.     Font.Assign(Panel1.Font);
  3179.     Left:=((Parent.ClientWidth-ClientWidth) div 2);
  3180.     Top:=MinLong(8,Abs(Parent.ClientHeight-ClientHeight) div 2);
  3181.     Show;
  3182.   end;
  3183. end;
  3184.  
  3185. Function TChartEditForm.InsertSeriesForm( EditorClass:TFormClass;
  3186.                                           Position:Integer;
  3187.                                           Const EditorTabName:String;
  3188.                                           AnObject:TPersistent):TForm;
  3189. Var OldTab:Integer;
  3190. begin
  3191.   OldTab:=PageControlSeries.PageIndex;
  3192.   PageControlSeries.Pages.Insert(Position,EditorTabName);
  3193.   result:=EditorClass.Create(Self);
  3194.   Inc(NumSeriesForms);
  3195.   TheSeriesForms[NumSeriesForms]:=result;
  3196.   AddSeriesForm(result,Position,Longint(AnObject));
  3197.   if OldTab=-1 then PageControlSeries.PageIndex:=0
  3198.                else PageControlSeries.PageIndex:=OldTab;
  3199. end;
  3200.  
  3201. procedure TChartEditForm.SERightMaChange(Sender: TObject);
  3202. begin
  3203.   if not CreatingForm then
  3204.   With TheChart do MarginRight:=ChangeMargin(SERightMa,MarginRight,MarginLeft);
  3205. end;
  3206.  
  3207. procedure TChartEditForm.SETopMaChange(Sender: TObject);
  3208. begin
  3209.   if not CreatingForm then
  3210.   With TheChart do MarginTop:=ChangeMargin(SETopMa,MarginTop,MarginBottom);
  3211. end;
  3212.  
  3213. procedure TChartEditForm.SEBotMaChange(Sender: TObject);
  3214. begin
  3215.   if not CreatingForm then
  3216.   With TheChart do MarginBottom:=ChangeMargin(SEBotMa,MarginBottom,MarginTop);
  3217. end;
  3218.  
  3219. procedure TChartEditForm.SELeftMaChange(Sender: TObject);
  3220. begin
  3221.   if not CreatingForm then
  3222.   With TheChart do MarginLeft:=ChangeMargin(SELeftMa,MarginLeft,MarginRight);
  3223. end;
  3224.  
  3225. procedure TChartEditForm.PageControlAxisChange(Sender: TObject;
  3226.   NewTab: Integer; var AllowChange: Boolean);
  3227. begin
  3228.   Case NewTab of
  3229.     0: SetAxisScales;
  3230.     1: SetAxisTitle;
  3231.     2: SetAxisLabels;
  3232.     3: SetAxisTicks;
  3233.     4: SetAxisPosition;
  3234.   end;
  3235. end;
  3236.  
  3237. procedure TChartEditForm.MainPageChange(Sender: TObject; NewTab: Integer;
  3238.   var AllowChange: Boolean);
  3239. begin
  3240.   MainPageChanging(Sender,AllowChange);
  3241.   CreatingForm:=True;
  3242.   if NewTab=1 then SetTabSeries;
  3243.   CreatingForm:=False;
  3244. end;
  3245.  
  3246. procedure TChartEditForm.PageControlSeriesChange(Sender: TObject;
  3247.   NewTab: Integer; var AllowChange: Boolean);
  3248. var t:Integer;
  3249. begin
  3250.   PageControlSeriesChanging(Self,AllowChange);
  3251.   CreatingForm:=True;
  3252.   for t:=1 to NumSeriesForms do
  3253.       if NewTab=(t-1) then
  3254.          if TheSeriesForms[t]<>nil then TheSeriesForms[t].Show;
  3255.   if NewTab=NumSeriesForms then SetTabSeriesGeneral else
  3256.   if NewTab=NumSeriesForms+1 then SetTabSeriesMarks else
  3257.   if NewTab=NumSeriesForms+2 then SetTabSeriesDataSource;
  3258.   CreatingForm:=False;
  3259. end;
  3260.  
  3261. procedure TChartEditForm.TabSubWallsChange(Sender: TObject;
  3262.   NewTab: Integer; var AllowChange: Boolean);
  3263. begin
  3264.   CreatingForm:=True;
  3265.   if NewTab=0 then SetTabWalls(TheChart.LeftWall) else
  3266.   if NewTab=1 then SetTabWalls(TheChart.BottomWall) else
  3267.                    SetTabWalls(TheChart.BackWall);
  3268.   CreatingForm:=False;
  3269. end;
  3270.  
  3271. procedure TChartEditForm.CBOrthogonalClick(Sender: TObject);
  3272. begin
  3273.   if not CreatingForm then
  3274.   begin
  3275.     TheChart.View3DOptions.Orthogonal:=CBOrthogonal.Checked;
  3276.     Refresh3DControls;
  3277.   end;
  3278. end;
  3279.  
  3280. procedure TChartEditForm.SBZoomChange(Sender: TObject);
  3281. begin
  3282.   if not CreatingForm then
  3283.   begin
  3284.     TheChart.View3DOptions.Zoom:=SBZoom.Position;
  3285.     LZoom.Caption:=IntToStr(TheChart.View3DOptions.Zoom)+'%';
  3286.   end;
  3287. end;
  3288.  
  3289. procedure TChartEditForm.CBMultiLineClick(Sender: TObject);
  3290. begin
  3291.   if not CreatingForm then
  3292.      TheAxis.LabelsMultiLine:=CBMultiLine.Checked;
  3293. end;
  3294.  
  3295. procedure TChartEditForm.CBGridCenterClick(Sender: TObject);
  3296. begin
  3297.   if not CreatingForm then
  3298.      TheAxis.GridCentered:=CBGridCenter.Checked;
  3299. end;
  3300.  
  3301. procedure TChartEditForm.CBLeftWallTransClick(Sender: TObject);
  3302. begin
  3303.   if not CreatingForm then
  3304.   With SelectedWall.Brush do
  3305.   if (Sender as TCheckBox).Checked then Style:=bsClear
  3306.                                    else Style:=bsSolid;
  3307. end;
  3308.  
  3309. procedure TChartEditForm.SBRotChange(Sender: TObject);
  3310. begin
  3311.   TheChart.View3DOptions.Rotation:=SBRot.Position;
  3312.   LRot.Caption:=IntToStr(TheChart.View3DOptions.Rotation);
  3313. end;
  3314.  
  3315. procedure TChartEditForm.SBElevChange(Sender: TObject);
  3316. begin
  3317.   TheChart.View3DOptions.Elevation:=SBElev.Position;
  3318.   LElev.Caption:=IntToStr(TheChart.View3DOptions.Elevation);
  3319. end;
  3320.  
  3321. procedure TChartEditForm.SBHorizOfChange(Sender: TObject);
  3322. begin
  3323.   TheChart.View3DOptions.HorizOffset:=SBHorizOf.Position;
  3324.   LHorizOf.Caption:=IntToStr(TheChart.View3DOptions.HorizOffset);
  3325. end;
  3326.  
  3327. procedure TChartEditForm.SBVertOfChange(Sender: TObject);
  3328. begin
  3329.   TheChart.View3DOptions.VertOffset:=SBVertOf.Position;
  3330.   LVertOf.Caption:=IntToStr(TheChart.View3DOptions.VertOffset);
  3331. end;
  3332.  
  3333. procedure TChartEditForm.SEAxisPosChange(Sender: TObject);
  3334. begin
  3335.   if not CreatingForm then TheAxis.PositionPercent:=SEAxisPos.Value;
  3336. end;
  3337.  
  3338. procedure TChartEditForm.SEAxisStartChange(Sender: TObject);
  3339. begin
  3340.   if not CreatingForm then
  3341.   begin
  3342.     if SEAxisStart.Value<TheAxis.EndPosition then
  3343.        TheAxis.StartPosition:=SEAxisStart.Value
  3344.     else
  3345.        SEAxisStart.Value:=Round(TheAxis.StartPosition);
  3346.   end;
  3347. end;
  3348.  
  3349. procedure TChartEditForm.SEAxisEndChange(Sender: TObject);
  3350. begin
  3351.   if not CreatingForm then
  3352.   begin
  3353.     if SEAxisEnd.Value>TheAxis.StartPosition then
  3354.        TheAxis.EndPosition:=SEAxisEnd.Value
  3355.     else
  3356.        SEAxisEnd.Value:=Round(TheAxis.EndPosition);
  3357.   end;
  3358. end;
  3359.  
  3360. procedure TChartEditForm.CBZoomFontsClick(Sender: TObject);
  3361. begin
  3362.   if not CreatingForm then
  3363.     TheChart.View3DOptions.ZoomText:=CBZoomFonts.Checked;
  3364. end;
  3365.  
  3366. procedure TChartEditForm.CBWallDarkBackClick(Sender: TObject);
  3367. begin
  3368.   SelectedWall.Dark3D:=(Sender as TCheckBox).Checked
  3369. end;
  3370.  
  3371. procedure TChartEditForm.Button5Click(Sender: TObject);
  3372. begin
  3373.   With SelectedTitle do Color:=EditColor(Self,Color);
  3374. end;
  3375.  
  3376. procedure TChartEditForm.SBPerspecChange(Sender: TObject);
  3377. begin
  3378.   TheChart.View3DOptions.Perspective:=SBPerspec.Position;
  3379.   LPerspec.Caption:=IntToStr(TheChart.View3DOptions.Perspective);
  3380. end;
  3381.  
  3382. initialization
  3383.   RegisterClass(TChartEditForm);
  3384. end.
  3385.